1
i have in jquery mobile when i passing parameter using change page.

$("#mytest-listview div.mytest-title a").live('click', function (event,data) {
    var cid = $(this).attr('id');
    console.log(cid);

    $.mobile.changePage('../mytestdetail/',{ type: "get", data: {"id":cid} , reloadPage:false, changeHash:true });

    $('#pgMyTestDetail').live('pageshow', function(){
        var id = $.urlParam('id');
        doLoadMyTest(id);

    });

    $.urlParam = function(name){
        var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
        return results[1] || 0;
    }
    event.preventDefault();

});

when i click on mytest title it pass the id of mytest to url and then i get the id value and show the all detail of mytest. here is url /test/testdetail/?id=26 , but when i get test detail page and i hit the ctrl+R it refresh the page but not show the test detail. whats the problem?

1
  • If you're still having trouble with this, my plug-in might help Commented Apr 4, 2014 at 21:59

2 Answers 2

1

As of version 1.4, jQuery Mobile does not support page parameters. For version 1.5, the roadmap includes "Hash/query params according specs".

A workaround would be to use a custom router such as Cameron Askew's paramsHandler.

Other router options include jquerymobile-router, which at the time of writing is not up-to-date with jQuery Mobile 1.4, or Backbone's router, which could require extensive integration to support jQuery Mobile's features.

Alternatively, click and vclick events can be intercepted and directly handled to add parameter support, e.g. saving the parameters in a variable before the page transition.

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

1 Comment

I think those router's may be out of date. I recently created a plug-in for jQM 1.4
0
    $("#mytest-listview div.mytest-title a").live("click", function (e) {
            e.preventDefault();
            var cid = $(this).attr('id');
            console.log(cid);
            $.mobile.changePage('../mytestdetail/', { type: "get", data: {"id": cid}, reloadPage: false, changeHash: true });


        });
    //});

    $(document).on("pageinit", "#pgTestDetail", function (e) {
        var cid = (($(this).data("url").indexOf("?") > 0) ? $(this).data("url") : window.location.href ).replace(/.*id=/, "");
        doLoadTest(cid);


I write above code and its works great even refresh the page using ctrl+r.

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.