Reputation: 1019
I retrieve the selected typeahead value by using this method:
$('ul.typeahead li.active').data('value');
I then set this equal to a variable, like so,
var foo = $('ul.typeahead li.active').data('value');
However, if I try and do something like this:
var foo = $('ul.typeahead li.active').data('value').replace( /\([^\)]+\)$/, '' );
it won't seem to update the value of foo even though when I console.log(foo) it actually is showing the right value for foo.
Can you please tell me what I could do to resolve this?
Upvotes: 3
Views: 1483
Reputation: 10092
Data returns an object and not a String
Try :
var foo = $('ul.typeahead li.active').data('value').first.replace( /\([^\)]+\)$/, '' );
Upvotes: 1