jquery-mobile - 如何将禁用 ajax 链接绑定到某个类

发布于 2024-10-09 09:11:16 字数 512 浏览 0 评论 0原文

我在 Jquery Mobile 中研究多列布局。

当用户打开多列页面时,我想禁用 JQM ajaxlinks 导航(并切换到“人工导航和历史记录”)。所以基本上我试图绑定到类名 =“ui-hash”的链接或列表项-blocked”。当用户离开页面时,我会重新打开 ajaxlinks。

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

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

语法有什么问题吗?

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

快乐!

的帮助,圣诞

谢谢您 需要更多代码,我可以举一个例子。

I working on a multicolumn layout in Jquery Mobile.

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.

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

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

Is there anything wrong with the syntax?

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!

Frequent

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

笑梦风尘 2024-10-16 09:11:17

如果您只想在某些链接上执行此行为,请将 data-ajax="false" 添加到链接

Add data-ajax="false" to the link if you only want this behavior on certain links

晨光如昨 2024-10-16 09:11:17
$(document).bind("mobileinit", function(){
  //Disable ajax link
  $('.disable-ajax').click(function(event){
    $.mobile.ajaxFormsEnabled = false;
  });
});
$(document).bind("mobileinit", function(){
  //Disable ajax link
  $('.disable-ajax').click(function(event){
    $.mobile.ajaxFormsEnabled = false;
  });
});
最美的太阳 2024-10-16 09:11:17

这个 $.mobile.* 是一堆很早就被使用的配置选项。这就是为什么他们在此处显示何时初始化它。此设置是全局设置。

你想做的事情很hacky。但我相信您可以在正确的时刻更改设置,这应该是以下之一:

  1. 在单击之前 - 在示例中尝试单击的 mousedown 事件 insteqad

  2. 在使用 JQM 处理项目之前,

    $.mobile.ajaxLinksEnabled = false;
    $('theNEWelement').appendTo('某处').page();
    $.mobile.ajaxLinksEnabled = false;

评论结果,我将编辑以标记哪一个有效。我暂时无法测试。

This $.mobile.* is a bunch of configuration options that are being used quite early. That's why they show here when to initialize it. This setting is a global one.

What you're trying to do is hacky. But I belive you can change the setting in the correct moment, which should be one of these:

  1. just before the click - try mousedown event insteqad of click in your example

  2. before the item is being pimped with JQM:

    $.mobile.ajaxLinksEnabled = false;
    $('theNEWelement').appendTo('somewhere').page();
    $.mobile.ajaxLinksEnabled = false;

Comment with results and I will edit to mark which one worked. I can't test it at the moment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文