Typeahead.js 清空时触发事件
Typeahead.js event fired when emptyed
我有 Typahead.js plagind 并且想在输入字段为空时将 data-id
属性设置为 ''
。现在我用它来设置 data-id
选择特定建议时,但是当它为空时无法捕获事件。
typeaheadFields.bind('typeahead:select', function (ev, suggestion) {
$(this).parent().find('.attribute-slider-category-id').attr('data-id', suggestion.id);
});
已修复:
typeaheadFields.keyup(function () {
if ($(this).val() == '') {
$(this).parent().find('.attribute-slider-category-id').attr('data-id', '');
}
});
我有 Typahead.js plagind 并且想在输入字段为空时将 data-id
属性设置为 ''
。现在我用它来设置 data-id
选择特定建议时,但是当它为空时无法捕获事件。
typeaheadFields.bind('typeahead:select', function (ev, suggestion) {
$(this).parent().find('.attribute-slider-category-id').attr('data-id', suggestion.id);
});
已修复:
typeaheadFields.keyup(function () {
if ($(this).val() == '') {
$(this).parent().find('.attribute-slider-category-id').attr('data-id', '');
}
});