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

Merged
merged 3 commits into from Aug 2, 2012

Projects

None yet

2 participants

@gseguin
Member
gseguin commented Jul 27, 2012

No description provided.

@johnbender johnbender commented on an outdated diff Jul 27, 2012
js/widgets/listview.filter.js
@@ -42,7 +42,10 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
lastval = $this.jqmData( "lastval" ) + "",
childItems = false,
itemtext = "",
- item;
+ item,
+ lbfEvent = new $.Event( "listviewbeforefilter" );
+
+ list.trigger( lbfEvent );
@johnbender
johnbender Jul 27, 2012 Contributor

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" );
@johnbender
Contributor

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.
@gseguin gseguin merged commit 9ea70df into jquery:master Aug 2, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment