开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜