I have Typahead.js plagind and want to set data-id
attribute to ''
when input field is empty. Now I'm using it to set data-id
when specific suggestion is selected, but when it is empty can't catch an event.
typeaheadFields.bind('typeahead:select', function (ev, suggestion) {
$(this).parent().find('.attribute-slider-category-id').attr('data-id', suggestion.id);
});
Fixed with this:
typeaheadFields.keyup(function () {
if ($(this).val() == '') {
$(this).parent().find('.attribute-slider-category-id').attr('data-id', '');
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.