Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
746 views
in Technique[技术] by (71.8m points)

jquery mobile - How to stop JQM from styling a page?

I have a JQM app with one specific page that I do not want styled.

All I have found so far is data-role='none' - but I don't want to have to apply that to every element on the page... Is there a way to turn if off just for this one page?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can use data-enhance="false" in conjunction with $.mobile.ignoreContentEnabled=true to stop the auto-enhancement that jQuery Mobile does to a pseudo-page:

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
$(document).on('mobileinit', function () {
    $.mobile.ignoreContentEnabled = true;
});
</script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>

<div data-enhance="false" data-role="page">
    ...
</div>?

The reason you have to change the ignoreContentEnabled flag is because it's CPU intensive to search parent elements for the data-attribute, so this is turned-off by default.

Here is a demo: http://jsfiddle.net/ZtJyL/1/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...