Note that there are some explanatory texts on larger screens.

plurals
  1. POunable to use different id's to open a panel on swipe in jquery mobile
    primarykey
    data
    text
    <p>i'm working on jquery mobile single page application so all my page are in index.php with different id's. now i want to open my left-panel on swipe.its working fine when i'm using it with one of my page having id home but i m unable to know that how can i use it with all my pages coz my all pages have different id's.</p> <p>Here is my jquery code to open a panel on swipe:</p> <pre><code>&lt;script type="text/javascript"&gt; $( document ).on( "pageinit", "#home", function() { $( document ).on( "swipeleft swiperight", "#home", function( e ) { // We check if there is no open panel on the page because otherwise // a swipe to close the left panel would also open the right panel (and v.v.). // We do this by checking the data that the framework stores on the page element (panel: open). if ( $.mobile.activePage.jqmData( "panel" ) !== "open" ) { if ( e.type === "swipeleft" ) { $( "#right-panel" ).panel( "open" ); } else if ( e.type === "swiperight" ) { $( "#left-panel" ).panel( "open" ); } } }); }); &lt;/script&gt; </code></pre> <p>Here is the code for opening the panel:</p> <pre><code>&lt;div data-role="header" data-theme="p" data-position="fixed"&gt; &lt;h1&gt;&lt;/h1&gt; &lt;a href="#left-panel" data-icon="bars" data-iconpos="notext" data-role="button"&gt;Menu&lt;/a&gt; &lt;/div&gt; &lt;a data-theme="d" data-corners="false" data-role="button" href="#"&gt; &lt;img src="images/pearl-logo.png" alt="rss" style="display: block; margin: 1.5em auto;"&gt;&lt;/a&gt; &lt;div data-role="panel" id="left-panel" data-position="left" data-display="overlay" data-dismissible="true" data-theme="c"&gt; &lt;ul data-role="listview" data-theme="d" data-divider-theme="d" data-icon="false" data-global-nav="docs" class="jqm-list"&gt; &lt;li data-role="list-divider"&gt;LINKS&lt;/li&gt; &lt;li&gt;&lt;a href="#home"&gt;Home&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#20years"&gt;20 Years&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#courses"&gt;Courses&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#events"&gt;Fun @ Pearl&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#gallery"&gt;Gallery&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#noida"&gt;Noida&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#jaipur"&gt;Jaipur&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#delhi"&gt;Delhi&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;img src="images/pearl-logo.png"&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Here are my few pages having different id's:</p> <pre><code>&lt;div data-role="page" id="home" data-url="home"&gt; &lt;div data-role="content"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div data-role="page" id="20years" data-url="20years"&gt; &lt;div data-role="content"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div data-role="page" id="gallery" data-url="gallery"&gt; &lt;div data-role="content"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>the panel is on all the pages.</p> <p>here is how i call the panel in my pages:</p> <pre><code>&lt;div data-role="page" id="20years" data-title="20years" data-url="20years"&gt; &lt;div data-role="appheader"&gt;&lt;/div&gt; &lt;div data-role="content"&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>and here is the jquery code :</p> <pre><code>&lt;script&gt; $(document).ready(function(e) { $('[data-role=page]').one('pagebeforeshow', function (event, ui) { $("#" + event.target.id).find("[data-role=appheader]").load("appheader.html", function(){ //$("#" + event.target.id).find("[data-role=panel]").trigger("pagecreate"); // refresh the page again // alert('ok'); $("#" + event.target.id).trigger("create"); }); }); }); &lt;/script&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload