Monday 15 April 2013

jquery mobile - JQM page id and data-url -


What is the connection between the page id and the data-url attribute? Is it OK to change the data-url attribute?

My point is that there is a page in which I am using the page using Param. I also specify the data-url in changepage. After going to that page, if I manually refresh the page then a new page is added because the data-url is different for that page. That is, the data-URL is similar to the page ID, hope to be clear on this. What should I do so that the page be changed during the page's manual refresh?

And, can someone please tell how JQ uses PageID and Data-URL? thank you in advanced.

data-url is used to track the page Element if the element is not explicitly set, all the pages embedded within the main application document have the same attribute code as data-url page id is. The first exception to this document is the first exception in the document. When you are requesting a page, jQuery Mobile first tries to locate a page with the matching data-url in a DOM. If he does not find such a page then it makes an Ajax request and loads a new page in the DOM.

You can solve this problem using one of the following methods:

Use the code below to go to the second page with the DOM To remove the second page.

  $ (document) .on ('pagehide', '# second-page', function (event), UI) {$ (event.target) .remove ();});   

In this way, when you are going to the first page, the second page will be removed from the DOM and your problem will be resolved.

OR :

Use:

  $. Mobile.changePage ('car-details.html', {Data: {id: this.id}}); Without using the   

dataUrl setting.

This creates a URL: ../car-details.html?id=my_val

The URL resides on the same refresh so you can still get the parameter and Data-url is similar to the page ID.

OR

Before changePage () check whether the data-url equals the second page ID The page with is present in the DOM and delete it manually.

  if ($ ("# second-page-id"). Length> 0 & amp; $ ("# second-page-id"). Attr ("Data - Url ") === 'Second Page-ID') {console.log ('Remove from DOM'); . Deleting $ ("# Second Page-ID"); }    

No comments:

Post a Comment