Permalink
Browse files

Filterable backcompat: Trigger listviewbeforefilter

Fixes gh-6679
  • Loading branch information...
gabrielschulhof committed Oct 29, 2013
1 parent 923ca08 commit b989774a9050a0ddedb271a8befc93810137ef59
@@ -65,6 +65,16 @@ $.widget( "mobile.filterable", $.mobile.filterable, {
this._setWidget( this.element.data( "mobile-" + evt.type.substring( 0, evt.type.length - 6 ) ) );
},
_trigger: function( type, event, data ) {
if ( this._widget && this._widget.widgetFullName === "mobile-listview" &&
type === "beforefilter" ) {
// Also trigger listviewbeforefilter if this widget is also a listview
this._widget._trigger( "beforefilter", event, data );
}
this._super( type, event, data );
},
_setWidget: function( widget ) {
if ( !this._widget && widget ) {
this._widget = widget;
@@ -308,4 +308,35 @@
], 500 );
});
module( "Filter widget backwards compatibility" );
asyncTest( "Triggering 'filterablebeforefilter' on a filtered listview also triggers 'listviewbeforefilter'", function() {
expect( 2 );
var input = $( "#test-backcompat-signal-emission-input" ),
list = $( "#test-backcompat-signal-emission" ),
eventNs = ".backcompatEventIsFiring";
$.testHelper.detailedEventCascade([
function() {
input.val( "a" ).trigger( "change" );
},
{
filterablebeforefilter: {
src: list,
event: "filterablebeforefilter" + eventNs + "1"
},
listviewbeforefilter: {
src: list,
event: "listviewbeforefilter" + eventNs + "1"
}
},
function( result ) {
deepEqual( result.filterablebeforefilter.timedOut, false, "Received 'filterablebeforefilter'" );
deepEqual( result.listviewbeforefilter.timedOut, false, "Received 'listviewbeforefilter'" );
start();
}
]);
});
})(jQuery);
@@ -24,6 +24,7 @@
"jquery.mobile.navigation",
"widgets/listview",
"widgets/filterable",
"widgets/filterable.backcompat",
"widgets/listview.autodividers",
"widgets/toolbar",
"widgets/collapsible",
@@ -306,6 +307,17 @@ <h1>Filterable</h1>
<p class="ui-screen-hidden">New York, NY</p>
</div>
<input id="test-backcompat-signal-emission-input"></input>
<ul id="test-backcompat-signal-emission"
data-nstest-role="listview"
data-nstest-filter="true"
data-nstest-input="#test-backcompat-signal-emission-input">
<li>San Francisco, CA</li>
<li>Portland, OR</li>
<li>Washington, DC</li>
<li>New York, NY</li>
</ul>
</div>
</div>

0 comments on commit b989774

Please sign in to comment.