1

I am building a jQuery mobile application using PhoneGap. I have to open a new page by passing some parameters of perivous page using jQuery mobile. For this I have tried to use local storage, like this:

$("li").click(function(){
    console.log("hi");
    var index = $(this).index();
    console.log("index"+ index);

    window.localStorage.setItem("date",userArray_date[index] );
    window.localStorage.setItem("title",userArray_title[index] );

    window.location.href='mypage.html';     
});

On another page I retrieved values like this:

var display_date = window.localStorage.getItem("date");
var display_title = window.localStorage.getItem("title");

$("#Date_Leaf").append(display_date);
$("#Title_Leaf").append(display_title);

This is working properly on an Android phone but does not work on Windows 7 phone. Can anybody tell me where I am going am wrong please?

1
  • even I try to use $.mobile.changePage('mypage.html?date'=dispaly_date); but windows emulator show error on loading page. Commented Aug 16, 2012 at 4:51

2 Answers 2

3

http://docs.phonegap.com/en/2.0.0/cordova_storage_storage.md.html#localStorage

try use local storage in onDeviceReady function

Sign up to request clarification or add additional context in comments.

Comments

2

We Use PhoneGap deviceready method for localstorage and it work fine. like:

document.addEventListener("deviceready", myMethod, false);
function myMethod(){

$("li").click(function(){


    var index = $(this).index();

    console.log("index"+ index);

    window.localStorage.setItem("date",userArray_date[index] );
    window.localStorage.setItem("title",userArray_title[index] );

window.location.href='mypage.html';
});}

and On mypage.html:

document.addEventListener("deviceready", page2Method, false);

function page2Method(){

  var display_date = window.localStorage.getItem("date");
  var display_title = window.localStorage.getItem("title");

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.