how to check if the transition name is valid in jquery.mobile?
I have a javascript method which accepts the transition name as a parameter and passe开发者_开发知识库s it to jquery.mobile for changing page:
$.mobile.changePage(renderedPage, { transition: transition, reverse: reverse });
Now I need to check if the transition name passed to my method is a valid transition. (this is because invalid transition name will cause a break in .changePage() method)
I browsed the source code of jquery.mobile but could not find a collection that contains all transition names or transition handlers.
Anybody has a trick to do this?
In jquery mobile, there are only six transitions available. you could just make sure that the given transition is in the array of available transitions. http://jquerymobile.com/demos/1.0a4.1/docs/pages/docs-transitions.html
var transitionArr = ["slide","slideup","slidedown","pop","fade","flip"];
$.mobile.changePage(renderedPage, {
transition: $.inArray(transition,transitionArr) == -1 ? transition : "slide",
reverse:reverse
});
However, i was unable to find an array or object in the core that directly referenced these transitions in a way that we could use to dynamically build this array.
精彩评论