Is there a way to pass a javascript object through the parameter in XML to another view? Or a json variable?
I’m not sure what the difference is between a javascript object and a json variable, but an acceptable workaround might be to serialize the object, then send it as a view parameter of type text
, and then deserialize it on the other end.
So for example in your first view:
XML
<button label="linktest" on-press="linktest" />
JS
function linktest() {
var testVar = {a: '1', b: '2'};
return link.paramtest(JSON.stringify(testVar))
}
Then, in the second “paramtest” view:
XML
<param name="test" type="text" />
JS
function init() {
var myVar = JSON.parse(view.test) ;
dialog('received ', myVar.b);
}
This should display “received 2”