jQuery Mobile触发器filterablebeforefilter [英] jQuery Mobile trigger filterablebeforefilter

查看:139
本文介绍了jQuery Mobile触发器filterablebeforefilter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这里缺少一些简单的东西.我创建了一个基本的jQuery MobileAutocomplete,例如 http://demos.jquerymobile. com/1.4.0/listview-autocomplete-remote/(使用我自己的数据源进行了一些修改)

I am hoping I am missing something simple here. I have created a basic jQuery MobileAutocomplete such as this http://demos.jquerymobile.com/1.4.0/listview-autocomplete-remote/ (with slight modifications using my own data source)

如示例所示,我具有功能

As suggested by the example, I have the function

$( "#autocomplete" ).on( "filterablebeforefilter", function ( e, data ) {
   //returns as a jquery listview using an ajax call
});

但是,我还有一个选择框(flipbox),它可以更改ajax调用的网址,我想知道在用相同的搜索词更改选择框后,是否有一种方法可以重新激发"该调用.我到目前为止为止

However I also have a select box (flipbox) which changes the url of the ajax call, I was wondering if there is a way to "refire" the call after the select box has changed with the same search terms. I've gotten so far as

$("#flip-select").change(function() {
    $("#autocomplete").trigger("filterablebeforefilter","something");
});

显然某事"不是过滤器期望的数据过滤器.那运行了函数,但是我不确定下一步要去哪里(或者我是否已经走了正确的道路).谢谢!

Obviously "something" isn't the data filterbeforefilter is expecting. That runs the function, but I'm not sure where to go next (or if I've even down the right path). Thanks!

推荐答案

看看我放在一起的这个演示:

Have a look at this demo I put together:

FIDDLE

FIDDLE

当flipswitch被选中,我得到的过滤的搜索输入,将其值设置为某些文本,然后触发输入上的变化事件.这使过滤器进入并调用filterablebeforefilter处理程序.

When the flipswitch is checked, I get the filterable's search input, set its value to some text and then trigger the change event on the input. This makes the filter go and call the filterablebeforefilter handler.

$("#flip-checkbox").on("change", function(){
    if (this.checked) {
        var inp = $( "#autocomplete" ).filterable( "option", "input" );
        $(inp).val("boston").trigger("change");
    }
});

为此,我要添加自己的搜索输入:

For this to work I am adding my own search input:

<form class="ui-filterable">
    <input id="filterBasic-input" data-type="search" />
</form>

然后我在UL中引用它:

And then I reference it in the UL:

<ul id="autocomplete" data-role="listview" data-inset="true" data-filter="true" data-filter-placeholder="Find a city..." data-filter-theme="a" data-input="#filterBasic-input"></ul>

这篇关于jQuery Mobile触发器filterablebeforefilter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆