jquery mobile collapsible-set在崩溃时执行jquery函数 [英] jquery mobile collapsible-set perform jquery function on collapse

查看:159
本文介绍了jquery mobile collapsible-set在崩溃时执行jquery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对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.

http://jsfiddle.net/6txWy/

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 and collapse events are deprecated and replaced with collapsibleexpand and collapsiblecollapse.

$(document).on("pagecreate", "#pageID", function () {
   $(".selector").on("collapsibleexpand collapsiblecollapse", function () {
      /* code */
   });
});

Demo

这篇关于jquery mobile collapsible-set在崩溃时执行jquery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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