Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Listview event: beforefilter #5198

demonslord opened this Issue Oct 18, 2012 · 4 comments


None yet
5 participants

Beforefilter event fires twice.

This line is executed twice:

Line #7444: listview._trigger( "beforefilter", "beforefilter", { input: this } );

"keyup" and "change" events of filter input.

Best Regards,
Alexander Bulei


arschmitz commented Oct 22, 2012

This should fire on both keyup and change this is because if someone pastes something in using right click or text is entered programmaticly keyup is not triggered so to ensure the data is filtered change must be used as well

@ghost ghost assigned jaspermdegroot Oct 23, 2012


jaspermdegroot commented Dec 16, 2012

This is an issue we have to look into.

Test case: http://jquerymobile.com/test/docs/demos/listviews/listview-filter-autocomplete.html

Steps to reproduce: Enter first 3 characters of a city name. Click on the clear button or view source button.
Because the "change" event is fired after you blur the input, the first click on one of those buttons triggers that event. Only after you click a second time the input field will be cleared or source view popup will be opened.
However, if we wouldn't bind to "change" the list wouldn't be updated when you click on the clear button.

Now we also bind to the "input" event to fix problems with multibyte characters (e.g. Japanese), the problem became a bit worse. When you enter a character both "keyup" and "input" fire and in the test case this means two Ajax calls. I don't think the "input" event is supported by all browsers that we support, so we can't just drop "keyup".

Regarding pasting text which @arschmitz mentioned: Maybe we can resolve this by binding to "paste" and "cut" events, but again browser support might be a problem. And we would still need "change" to update the list when the clear button is clicked, unless we make this trigger a "clear" event or something.

cc: @gseguin

@ghost ghost assigned gseguin Jan 4, 2013


gseguin commented Jan 4, 2013

After talking with @arschmitz and @ugomobi we decided that the keyUp handler should trigger once and only once per event whether it is keyup, change or input for the same value. I've implemented a fix I'll issue a PR once I have a test for it.

@gseguin gseguin added a commit to gseguin/jquery-mobile that referenced this issue Jan 4, 2013

@gseguin gseguin Listview test: Added test case for issue #5198 88e86a1

@gseguin gseguin closed this in ec88ea2 Jan 9, 2013

@ugomobi can I trigger keyup with character on listview search filter programmatically? I missing around here but can get it to work. http://fiddle.jshell.net/Palestinian/MZHXU/ is there a way to enter characters into search input programmatically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment