How-to store variable beetween jQM pages?

后端 未结 4 1468
忘掉有多难
忘掉有多难 2020-12-11 10:40

How do I pass a variable like username between two jQueryMobile pages?

or two regular pages for that matter, having the variable as global does not work, since at th

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-11 11:10

    You can pass it in the query string as long as you disable ajax on the hyperlink between the two pages.

    Next page
    

    You miss out on the beneficial features of jQuery mobile transitions, but at least you can successfully pass variables between pages.

    Update:

    From the documentation:

    Passing parameters between pages:

    jQuery Mobile does not support query parameter passing to internal/embedded pages...

    The documentation then goes on to suggest two plugins which I have not tried. Page params plugin and jquery mobile routing plugin.

    Be sure to check out the documentation page linked above for their explanation on why passing parameters shouldn't work but if you load the page without the hashing (by disabling the ajax behavior) then you should be fine -- at least in my experience.

提交回复
热议问题