jquery mobile collapsible-set在崩溃时执行jquery函数 [英] jquery mobile collapsible-set perform jquery function on collapse
问题描述
我正在尝试对jquery mobile collapsible-set的崩溃/展开实施一项操作。我正在运行jquery.mobile-1.4.4和jquery-1.11.0。
我在小提琴上发布了代码来测试它是否工作,但它没有。此功能适用于旧版jQuery Mobile和jQuery。
://jsfiddle.net/6txWy/HTLM:
< div id =footballdata-role =collapsible-set>
< div data-role =collapsibledata-collapsed =false>
< h3>第1部分< / h3>
< p>我是第1部分的可折叠设置内容。< / p>
< / div>
< div data-role =collapsible>
< h3>第2部分< / h3>
< p>我是第2部分的可折叠设置内容。< / p>
< / div>
JS:
$ b $
$('#football')。bind('expand',function(){
alert('Expanded'); $ b'b})。bind('collapse',function(){
alert('Collapsed');
});
有谁知道一种方法来实现我想要做的事情?
在此先感谢!
从jQuery Mobile 1.4开始, expand
和 collapse
事件已被弃用,并替换为 collapsibleexpand
和 collapsiblecollapse
。
$(document).on(pagecreate,#pageID ,function(){
$(。selector)。on(collapsibleexpand collapsiblecollapse,function(){
/ * code * /
});
}) ;
I'm trying to implement an action on collapse/expand of jquery mobile collapsible-set. I'm running jquery.mobile-1.4.4 and jquery-1.11.0.
I've posted code on fiddle to test if it works but it does not. This feature worked on older versions of jquery mobile and jquery.
HTLM:
<div id="football" data-role="collapsible-set"> <div data-role="collapsible" data-collapsed="false"> <h3>Section 1</h3> <p>I'm the collapsible set content for section 1.</p> </div> <div data-role="collapsible"> <h3>Section 2</h3> <p>I'm the collapsible set content for section 2.</p> </div>
JS:
$('#football').bind('expand', function () { alert('Expanded'); }).bind('collapse', function () { alert('Collapsed'); });
Does anyone know of a way to achieve what I'm trying to do??
Thanks in advance!
解决方案As of jQuery Mobile 1.4,
expand
andcollapse
events are deprecated and replaced withcollapsibleexpand
andcollapsiblecollapse
.$(document).on("pagecreate", "#pageID", function () { $(".selector").on("collapsibleexpand collapsiblecollapse", function () { /* code */ }); });
这篇关于jquery mobile collapsible-set在崩溃时执行jquery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!