开发者

JQM (jQueryMobile) Access to URL history?

I have a issue with being able to link back to the home page from a AJAX response from a Multi-page layout form submission

The structure

index.php has multi-page agreement (index.php#agreement)

#agreement has a form that is using the default AJAX call for submission to (agreement.php)

From agreement.php I can go back to the last page (#agreement) which is expe开发者_开发技巧cted but now I wanted to go back to the index.php page.

I can easily put href="index.php" but then the session looses it values.

Is there a way to go back two steps? or access the URL history and point to a specific page without loosing any of the data in the form(s)?

I have binded agreement.php using this code in index.php

$('#agreement_status').live('pageshow',function(event, ui){
    // Button action
    $('#back_home').click(function(){
        window.history.back(); // this goes back one page to index.php#agreement
        window.history.back(-2); // this goes back one page to index.php#agreement
        $.mobile.changePage("#index", "slideup"); // this works but appends the hashtag in the URL which breaks the other functionality 
    });
});

In agreement.php I have this code

<a id="back_home" 
   data-role="button" 
   data-icon="home" 
   data-theme="z" 
   data-inline="true" 
   style="float:right;">
    Home
</a>


Well this is not really an answer to my question but it did solve my problem:

agreement.php back button code, use the data-rel="back" option in the anchor tag and add a div tag with name/id agreement_status

<a data-rel="back" 
   data-role="button" 
   data-icon="home" 
   data-theme="z" 
   data-inline="true" 
   style="float:right;">
    Home
</a>

In the index.php page, add this to your java script

$('#agreement_status').live('pagehide',function(event, ui){
    window.history.back();
});

What happen is the pagehide fires when the agreement_status page is hidden, so you will be on the #agreement page. Then with window.history.back(); we are able to go back to the index.php page and still keep all the data in tacked without the need for a refresh of the page


try this

        window.location.href = "/index.php";
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜