How to pass a variable between pages WinJS?
Asked Answered
C

2

5

I'm trying to pass two variables from one page to the next. How would I go about doing this?

Callipash answered 6/1, 2013 at 5:5 Comment(2)
Do you really mean variables or parameters?Inveigh
Well, values in variables. I need to pass a string and an integer.Callipash
V
16

Put this code in first page:

WinJS.Navigation.navigate("/pages/secondpage.html", yourvalue);

Then in second page to retrive the data use:

ready: function (element, options) {
    //your data yourvalue is inside options parametr 
}

Very good example about navigation

WinJS navigation example

WinJS navigation example 2

Virulent answered 6/1, 2013 at 9:27 Comment(3)
Can I only pass one value?Callipash
By navigation function only one value. But you can pass a object or array. Se the firs link for more information.Virulent
Thank you so much! I finally get it! lol...I was able to pass the variables successfully!Callipash
P
6

Just wanted to include an example of passing multiple values as Norbert answered in his comment.

WinJS.Navigation.navigate("/pages/page2/page2.html", {value1:"hello",value2:"world"}
Pulcheria answered 6/1, 2013 at 15:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.