1

We encounter the following problems with Jquery Mobile. Our site is divided in a mobile and a fixed desktop site. Both use the same database and php code. Only the templates are different.

On our mobile site we use Jquery mobile for a better user experience and that works fine. However we integrated a button "goto desktop". This link should bring us back to our "normal" desktop site.
But there is the problem. In the desktop-site, Jquery mobile is still activated and it replaces drop down fields, input fields and make a complete mess of the desktop site.

We tried everything to disable JQM but nothing seems to work.

How we can switch from our mobile site template to the desktop site template and disable JQM completely when we are on the desktop template?

Thanks a lot for help!

4

1 回答 1

1

可用的解决方案很少,但只有一个会真正做到。

工作示例:http: //jsfiddle.net/Gajotres/NvEcW/

需要的东西很少,首先我们需要设置:

<script>
    $(document).on('mobileinit', function () {
        $.mobile.ignoreContentEnabled = true;
    });
</script>

它将使我们能够以编程方式打开/关闭内容增强。如果你还不知道这个mobileinit事件必须在 jQuery Mobile 初始化之前但在 jQuery 初始化之后进行初始化。这必须始终是页面的一部分。

还有最后一步。当我们想从移动页面移动到桌面页面时,我们需要重新加载页面并使用这个 javascript:

$(document).on('pagebeforecreate', '#index', function(){ 
    $(this).attr('data-enhance','false');
});

Pagebeforecreate事件很重要,因为此时内容仍未增强,属性data- enhance = false 将阻止任何进一步的页面增强。如果您想再次打开它,只需将属性值设置为 true。

如果您想要更多解决方案,请查看我的其他答案,搜索主题标记增强预防方法jQuery Mobile:动态添加内容的标记增强

于 2013-05-11T22:58:42.843 回答