0

I'm new in jquerymobile, so, how can i migrate from a simple $.ajax() call to a $.mobile.changePage ?

my normal ajax its something like this (from a click event):

$.ajax({
    url: 'mobile/' + content,
    type: 'GET',
    success: function (data) {
        $(".content").html(data);
    },
    error: function (XMLHTTPRequest) {
    }
});

basicly, all the ajax call (some simple html) will be droped inside the $(".content");

so, how can i do this, using changePage?

i try this, but he only fade the page and nothing happen, i think my target is missing, dont know.

$(".bottom-but-list li").on("click", function () {
    var content = $(this).attr("class").split(" ")[0]; // get the content to url

    $.mobile.changePage("mobile/" + content, {
        transition: "flip",
        reverse: true,
        changeHash: false,
        pageContainer: $("#page")
    });
});

html:

<div id="main-content" class="content">
     <!-- ajax should load here -->
 </div>

what i'm missing ?

Ricardo Binns
  • 3,228
  • 6
  • 44
  • 71
  • Have you try to use $.mobile.loadPage() instead? – A. Wolff Nov 15 '12 at 19:37
  • try it now, but nothing happen. – Ricardo Binns Nov 15 '12 at 19:45
  • $.mobile.changePage should work - it calls $.mobile.loadPage() under the hood. I'm just wondering if you are getting any JS errors in the console? The syntax looks correct. I'm a little sus why you need to specify the pageContainer. jQuery Mobile uses the body as the container by default, and that's usually what you want to go with. – asgeo1 Nov 15 '12 at 19:45
  • pageContainer i put because i was trying to load the ajax result inside this element. Imagine that i have `home.php` , inside this page, i have a basestructure with menus and others stuffs, and there are the `div` `.content` where the `changePage` method should drop the result inside of it. – Ricardo Binns Nov 15 '12 at 19:49
  • and i dont have any erros in console, remember that the other page that i'm trying to load inside of `.content` have only simple html, no `` and anything else. – Ricardo Binns Nov 15 '12 at 19:50
  • debuging now, i take it off the pageContainer and i receive a msg as `undefined` after transition effect. – Ricardo Binns Nov 15 '12 at 19:53

0 Answers0