سؤال

I have a form field which uses Jorn Zaefferer's "autocomplete" jQuery plugin. If i type some text, then select part of it and hit backspace, the autocomplete list updates. But if i hit delete instead of backspace, the autocomplete list disappears.

I'm looking at the code for the plugin and it looks like the autocomplete updater is triggered by a keydown event in the field, and both backspace and delete trigger a keydown.

Is there a fundamental difference between backspace and delete that could be causing this ?

هل كانت مفيدة؟

المحلول

If you look at the onChange() method, Del has a special purpose - to hide the autocomplete list:

function onChange(crap, skipPrevCheck) {
    if( lastKeyPressCode == KEY.DEL ) {
        select.hide();
        return;
    }

So no, there's no fundamental difference in event behavior here, this is just how the autocomplete plugin is designed, the delete key is specifically intended to hide the list.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top