jQuery mobile swipe content only
css, html, jquery, jquery-mobile
Solution
You can cheat here, there's a way you can change page in jQM but make it look like only content has been changed. It can be done if you place a data-id="footer" attribute in every header and every footer.
I have created a working jsFiddle example for you: http://jsfiddle.net/Gajotres/NV6Py/
<!DOCTYPE html>
<html>
<head>
<title>Share QR</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<article data-role="page" id="article1">
<div data-role="header" data-theme="b" data-position="fixed" data-id="footer">
<h1>Articles</h1>
</div>
<div data-role="content">
<p>Article 1</p>
</div>
<div data-role="footer" data-theme="b" data-position="fixed" data-id="footer">
<h1>Footer</h1>
</div>
</article>
<article data-role="page" id="article2">
<div data-role="header" data-theme="b" data-position="fixed" data-id="footer">
<a href="#article1" data-icon="home" data-iconpos="notext">Home</a>
<h1>Articles</h1>
</div>
<div data-role="content">
<p>Article 2</p>
</div>
<div data-role="footer" data-theme="b" data-position="fixed" data-id="footer">
<h1>Footer</h1>
</div>
</article>
<article data-role="page" id="article3">
<div data-role="header" data-theme="b" data-position="fixed" data-id="footer">
<a href="#article1" data-icon="home" data-iconpos="notext">Home</a>
<h1>Articles</h1>
</div>
<div data-role="content">
<p>Article 3</p>
</div>
<div data-role="footer" data-theme="b" data-position="fixed" data-id="footer">
<h1>Footer</h1>
</div>
</article>
</body>
</html>
In case you want to prevent jQM page styling you can do it with a help of a data-enhance="false" attribute, it must be placed in page/article container and initialized with a :
<script>
$(document).on('mobileinit', function () {
$.mobile.ignoreContentEnabled = true;
});
</script>
Also remember, mobileinit event must be initialized before jQM js is loaded.
I have also a working example of this : http://jsfiddle.net/Gajotres/5gXKj/, this is a same example like top one but without jQM page markup enhancement.
Problem
So I used the jquery mobile ui to do a page, swipe left/right, now this dosen't work for me since I just want to swipe only the content, not the entery body of the page, I tried to use `data-role="content"` but It doesn't work anymore only with `data-role="page"` is it posibile to have that swipe animation, but only for the content? I have some `<article>` and I want to swipe them left/right....but I don't want to swipe the header and other things..just the middle section. And also to disable that stupid jquery mobile theme if posibile. //Le Code structure ``` <header data-role="header"> .... </header> <section> <!-- only this part I want to swipe, one article at a time --> <article data-role="page"> ..... </article> <article data-role="page"> ..... </article> <article data-role="page"> ..... </article> <article data-role="page"> ..... </article> <!-- only this part I want to swipe, one article at a time --> </section> <footer> ... </footer> $('article').bind("swipeleft", function(){ var nextpage = $(this).next('article[data-role="page"]'); // swipe using id of next page if exists if (nextpage.length > 0) { $.mobile.changePage(nextpage, {transition: "slide", reverse: false}, true, true); } }); $('article').bind("swiperight", function(){ var prevpage = $(this).prev('article[data-role="page"]'); if (prevpage.length > 0) { $.mobile.changePage(prevpage, {transition: "slide", reverse: true}, true, true); } }); ```