cordova&jquery:value sent to another static html page

后端 未结 3 817
谎友^
谎友^ 2020-12-06 16:01

I\'m doing an ios web app using Cordova and JQuery. I create the index.html which has a 3-row list view. when the row is clicked, the page will cha

相关标签:
3条回答
  • 2020-12-06 16:07

    check this example here, Hope it will help

    http://wpcertification.blogspot.com/2012/05/using-jquery-mobile-in-phonegapcordova.html

    0 讨论(0)
  • 2020-12-06 16:13

    https://stackoverflow.com/a/16497284/3169868 answers this well. For cordova+wp8, the option with LocalStorage is easy to implement.

    0 讨论(0)
  • 2020-12-06 16:15

    If you want a value from one page to another you have few options (same rules apply for single jQM html with multiple page's and for jQM project built around multiple html files):

    I. On the second page use pagebeforeshow and retrieve all needed data through a data object. Lets say you have 2 html files, first html has an id "page1" and second one has an id "page2"), example:

    $('#page2').live('pagebeforeshow', function (e, data) {
        alert(data.prevPage.find('div[data-role="content"]').attr('id'));
    });
    

    II. Second option is to create a shared object which will be used as data storage:

    var storeObject = {
        someValue : '1',
        anotherValue : '2'
    }
    

    This is an easiest solution but it will only work while ajax page loading is active.

    III. You can pass values with changePage:

    $.mobile.changePage('page2.html', { dataUrl : "page2.html?paremeter=123", data : { 'paremeter' : '123' }, reloadPage : true, changeHash : true });
    

    and read them like this:

    $('#page2').live('pagebeforeshow', function (e, data) {
        var paremeter = $(this).data("url").split("?")[1];;
        paremeter = paremeter.replace("paremeter=","");   
        alert(paremeter);
    });
    

    More info

    If you want to learn more about this topic take a look at this article. You will find several solutions with examples.

    0 讨论(0)
提交回复
热议问题