jquery-mobile-如何将禁用的ajax链接绑定到某个类 [英] jquery-mobile - how can I bind disable ajax links to a certain class

查看:85
本文介绍了jquery-mobile-如何将禁用的ajax链接绑定到某个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Jquery Mobile中处理多列布局.

I working on a multicolumn layout in Jquery Mobile.

当用户打开一个多列页面时,我想禁用JQM ajaxlinks导航(并切换到人工导航和历史记录".因此,基本上,我试图绑定到一个类名称为=的链接或列表项) ui-hash-blocked".当用户离开页面时,我将ajaxlinks重新打开.

When the user opens a multicolumn page, I want to disable the JQM ajaxlinks navigation (and switch to "artificial navigation and history". So basically I'm trying to bind to a link or list item with a class name ="ui-hash-blocked". When the user leaves the page, I'm switching ajaxlinks back on.

我喜欢这个主意,但无法使此代码正常工作(错误:$ .mobile'[undefined])

I like the idea but cannot get this code to work (Error: $.mobile' [undefined])

$('.ui-hash-block').click(function ()
             {
             $.mobile.ajaxLinksEnabled = false;               
             });

语法有什么问题吗?

我知道在启动JQM之前调用$ .mobile会出错,但是由于我仅在单击链接/列表项时才调用此函数,因此JQM应该已经启动.

I know the error from calling $.mobile before initiating JQM, but since I'm only calling this function when the link/list item is clicked, JQM should have already been initiated.

感谢帮助&圣诞快乐!

Thanks for help & Merry Xmas!

频繁

PS:如果您需要更多代码,我可以举一个例子.

PS: if you need more code, I can put a up an example.

推荐答案

$(document).bind("mobileinit", function(){
  //Disable ajax link
  $('.disable-ajax').click(function(event){
    $.mobile.ajaxFormsEnabled = false;
  });
});

这篇关于jquery-mobile-如何将禁用的ajax链接绑定到某个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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