Jquery mobile change page with page transition from javascript

I am making transitions using this page: http://jquerymobile.com/demos/1.2.0/docs/pages/page-transitions.html

I make the transition when I click on the link:

<a href="#page1" data-transition="slide" data-role="button" > Submit </a>

This makes the slide transition.

If I need to change the data transition attribute in data-transition = "none", I will not get any transition.

Now I want to do some logic before making the transition. In other words, it would be nice if I could perform the same transition with javascript. This is what I have right now:

function GoTopage1()
{
    if(someVar == true)
        window.location = "#page1";
}

and my link is now similar:

<a onclick="GoTopage1()" data-transition="slide" data-role="button" > Submit </a>

This code works, but I lost the slide transition. When you click on the link, I get a default transition that goes into transition. How can I make the transition with the code?


Edit

, , :

:

<a id="t1" href="#page1"  data-transition="slide" ></a>

:

function GoTopage1()
{
    if(someVar == true)
        $("#t1").click(); // simulate link click        
}
+5
2

, , onclick anchor, , jQuery mobile, , : " - ".

, $.mobile.changePage() jQuery-mobile window.location. jQuery- .

, jQuery hashchange, , location.hash . :

http://jquerymobile.com/demos/1.2.0/docs/pages/page-navmodel.html

+1

:

  • $.mobile.navigate("#bar", {transition: "slide", info: "info about the #bar hash"});
  • $.mobile.pageContainer.pagecontainer("change", "target", {transition: "flow", changeHash: false, reload: true})

, $.mobile.changePage() . http://api.jquerymobile.com/jQuery.mobile.changePage/

, , . , . Google, StackOverflow.

0

All Articles