Wondering Coder
Wondering Coder

Reputation: 1702

$.mobile.changePage(); don't trigger in my next page?

im using $.mobile.changePage(); to go to a page. What's odd is in my index page it works but if i click on my next page and trigger the swipedown themobile.change it doesn't work now.. I know that my swipedown event is not the issue here cause tried to comment themobile.changepageand insert an alert function and it fired.

Process: In my Index page. $.mobile.changePage event work

$(document).delegate('.front-page-down','swipedown', function (event) {
    $.mobile.changePage('#notification', { transition: "slidedown"});
});

Go to a next page e.g page2 and tried to trigger my swipe event, mobile.changePage doesn't work.

$(document).delegate('.sns-down','swipedown', function (event) {
    //$.mobile.changePage('#featured', { transition: "slidedown"}); // this don't work in my next page
    alert("BOOM SNS");
});

Anyone know why this happens? The function changePage is enclose to an delegate function. I'm not using any document.ready() function.

FYI. For the mobile.changePage to work in my page2 I would have to refresh the page manually. hmmm

Help anyone.

Upvotes: 0

Views: 1018

Answers (2)

Michele
Michele

Reputation: 1

Take a look at this link at the "Scripts & styles in the head" section you could find the solution. put your script into the body tag and then you don't need to refresh your page! I hope that is useful for you problem

Upvotes: 0

SERPRO
SERPRO

Reputation: 10067

This is how I would do that with jQuery Mobile

$('.sns-down').each( function(){
    $(this).live('swipedown', function (event) {
        //$.mobile.changePage('#featured', { transition: "slidedown"}); // this don't work in my next page
        alert("BOOM SNS");
    });
});

if that doesn't work.. you can try to reload jquery mobile for that page with:

$.mobile.activePage.page("destroy").page();

before you bind the swipedown event.

Upvotes: 1

Related Questions