Skip to content
This repository

Proposed fix for #4721: Added a "listviewbeforefilter" event #4760

Merged
merged 3 commits into from almost 2 years ago

2 participants

Ghislain Seguin John Bender
Ghislain Seguin
Collaborator

No description provided.

js/widgets/listview.filter.js
@@ -42,7 +42,10 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
42 42 lastval = $this.jqmData( "lastval" ) + "",
43 43 childItems = false,
44 44 itemtext = "",
45   - item;
  45 + item,
  46 + lbfEvent = new $.Event( "listviewbeforefilter" );
  47 +
  48 + list.trigger( lbfEvent );
1
John Bender
johnbender added a note

I would use the listview object to trigger the event, because the prefix is dictated in the widget definition. So I would do something like:

listview._trigger( "beforefilter" );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
John Bender

Two quick thoughts:

  1. I wonder if we can provide the search field easily after we've added it. That way we're not proxying events and people can do all the weird things they want without us having to predict what they might be. Honestly I'm having a hard time thinking of a sane way to do this outside of defining a callback.
  2. If we end up going the event trigger route should probably include the element as part of the data on the event so they have direct access to it.
Ghislain Seguin gseguin merged commit 9ea70df into from
Ghislain Seguin gseguin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 2 additions and 0 deletions. Show diff stats Hide diff stats

  1. +2 0  js/widgets/listview.filter.js
2  js/widgets/listview.filter.js
@@ -44,6 +44,8 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
44 44 itemtext = "",
45 45 item;
46 46
  47 + listview._trigger( "beforefilter", "beforefilter", { input: this } );
  48 +
47 49 // Change val as lastval for next execution
48 50 $this.jqmData( "lastval" , val );
49 51 if ( val.length < lastval.length || val.indexOf( lastval ) !== 0 ) {

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.