[英]Typeahead.js event fired when emptyed
I have Typahead.js plagind and want to set data-id
attribute to ''
when input field is empty. 我有Typahead.js plagind,想在输入字段为空时将
data-id
属性设置为''
。 Now I'm using it to set data-id
when specific suggestion is selected, but when it is empty can't catch an event. 现在,当选择了特定建议时,我将使用它来设置
data-id
,但是当其为空时将无法捕获事件。
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', '');
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.