question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Duplicate data attributes of input

See original GitHub issue

I’m having problems with the component due to the hidden input created has the data-attributes of the original input copied. I mean, having:

<input type='text' id='x' name='x' data-role="x" class='form-control'/>

So I configure the typeahead for the object $(‘#x’). Once created I find:

<input type='text' id='x' name='x' data-role="x" class='form-control tt-input' />
<input type='text' data-role="x" class='form-control tt-hint'/>

The problem is that, after I use $(‘[data-role=x]’).val() and I expect only 1 result but I got 2 instead.

I would like that the created input for the component doesn’t copy the data- attributes as doesn’t copy name or id. Thanks a lot.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
erkuritacommented, Oct 27, 2015

The biggest issue with this problem is React.js. Since React assigns data-react-id attributes to most elements (if not all), when the typeahead is initialized it creates 2 inputs with the same data-react-id and React goes bonkers.

Perhaps we could have a setting with which turn on or off this behaviour?

0reactions
benedict-wcommented, Jul 24, 2019

I’m also getting Google Web Console crawler errors for duplicate itemprop=“query-input” field on site search box

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can an HTML element have the same attribute twice?
It's not technically valid, but every browser will ignore duplicate attributes in HTML documents and use the first value ( data-foo="bar" in ...
Read more >
Using data attributes - Learn web development | MDN
To get a data attribute through the dataset object, get the property by the part of the attribute name after data- (note that...
Read more >
Copy all the attributes of one element and apply them to ...
Select both elements(target and source element). · Get the properties of source element by using el.prop('attributes') method. · Use .each() ...
Read more >
Prevent duplicate values input based on 1 entity attribute
Hi,. Is there anyway to prevent the input to an Entity from user if there is a duplicate in entry of an attribute...
Read more >
Identifying duplicate attributes in field using QGIS
And of course you can enable a data derived override based on the the same. For example, if you want to highlight labels...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found