jquery-mobile - 如何将禁用 ajax 链接绑定到某个类
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您只想在某些链接上执行此行为,请将
data-ajax="false"
添加到链接Add
data-ajax="false"
to the link if you only want this behavior on certain links这个 $.mobile.* 是一堆很早就被使用的配置选项。这就是为什么他们在此处显示何时初始化它。此设置是全局设置。
你想做的事情很hacky。但我相信您可以在正确的时刻更改设置,这应该是以下之一:
在单击之前 - 在示例中尝试单击的 mousedown 事件 insteqad
:
$.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:
just before the click - try mousedown event insteqad of click in your example
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.