dynamic - jQuery Mobile inject external page using URL with jquery -
im try inject in index other pages "profile.html" or "contact.html". pages want keep in memory , user can go back, , others dont. pages want load in main index page <\div>. can give code example? something that
what describe problem, default way how jquery-mobile loads "pages" dom.
lets build example:
index.html
- header referencesto jquery, jquery-mobile etc.
- div data-role="page" > #index
- div data-role-"page" > #page1
page2.html
- div data-role="page" > #page2
page3.html
- header references jquery, jquery-mobile etc.
- div data-role="page" > #page3
what happen when link x y ?
- open index.html
- the fist div data-role="page" displayed
- in case #index
- pages inside of dom (#index, #page1)
- link index.html(#index) #page1
- nothing loaded
- the page #page1 shown
- pages inside of dom (#index, #page1)
- link index.html page2.html
- the first div data-role="page" page2.html loaded dom
- pages inside of dom (#index, #page1, #page2)
- if reload page, see unstyled html page, because page2.html has no js or css file in head
- you can link #index, #page1 , #page2 because of them inside of dom
- link page3.html data-ajax="false"
- the whole page3.html loaded.
- pages inside of dom (#page3)
- a can still link page2.html
- you can link first page of index.html, not second page.
you can not load more first page of multipage .html file ajax. load multipage, have load .html file without ajax (data-ajax="false")
code index.html
<!doctype html> <html> <head> <meta charset="utf-8" /> <title></title> <!-- jquery --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <!-- jquery mobile --> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script> </head> <body> <!-- index --> <div data-role="page" id="index" data-title="index.html"> <!-- header --> <div data-role="header" data-position="fixed"> <h1>index.html(#index)</h1> </div> <!-- /header --> <!-- content --> <div role="main" class="ui-content"> <a href="#" class="ui-btn ui-state-persist ui-btn-active">index.html</a> <a href="#page1" class="ui-btn">page 1 (intern)</a> <a href="page2.html" class="ui-btn">page 2 (seperate .html file)</a> <a href="page3.html" data-ajax="false" class="ui-btn">page 3 (seperate .html file - no-ajax)</a> </div> <!-- /content --> </div> <!-- /index --> <!-- page1 --> <div data-role="page" id="page1" data-title="index.html#page1"> <!-- header --> <div data-role="header" data-position="fixed"> <h1>index.html#page1</h1> </div> <!-- /header --> <!-- content --> <div role="main" class="ui-content"> <a href="#index" class="ui-btn ">index.html</a> <a href="#page1" class="ui-btn ui-state-persist ui-btn-active">page 1 (intern)</a> <a href="page2.html" class="ui-btn">page 2 (seperate .html file)</a> <a href="page3.html" data-ajax="false" class="ui-btn">page 3 (seperate .html file - no-ajax)</a> </div> <!-- /content --> </div> <!-- /page1 --> </body> </html>
code of page2.html
<script> alert("hello page 2"); </script> <!-- page2 --> <div data-role="page" id="page2" data-title="page2.html"> <!-- header --> <div data-role="header" data-position="fixed"> <h1>page2.html</h1> </div> <!-- /header --> <!-- content --> <div role="main" class="ui-content"> <a href="#index" class="ui-btn ">index.html</a> <a href="#page1" class="ui-btn">page 1 (inside index.html)</a> <a href="page2.html" class="ui-btn ui-state-persist ui-btn-active">page 2 (seperate .html file - ajax)</a> <a href="page3.html" data-ajax="false" class="ui-btn">page 3 (seperate .html file - no-ajax)</a> </div> <!-- /content --> </div> <!-- /page2 -->
code of page3.html
<!doctype html> <html> <head> <meta charset="utf-8" /> <title></title> <!-- jquery --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <!-- jquery mobile --> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.min.js"></script> <script> alert("hello page 3"); </script> </head> <body> <!-- page2 --> <div data-role="page" id="page3" data-title="page3.html"> <!-- header --> <div data-role="header" data-position="fixed"> <h1>page3.html</h1> </div> <!-- /header --> <!-- content --> <div role="main" class="ui-content"> <a href="index.html" class="ui-btn ">index.html (first page of multipage)</a> <a href="index.html#page1" class="ui-btn">page 1 ((second page of multipage))</a> <a href="page2.html" class="ui-btn">page 2 (seperate .html file - ajax)</a> <a href="page2.html" data-ajax="false" class="ui-btn ui-state-persist ui-btn-active">page 3 (seperate .html file - no-ajax)</a> </div> <!-- /content --> </div> <!-- /page2 --> </body> </html>
Comments
Post a Comment