jquery mobile - 如何改变函数调用中的选项?
我正在尝试将两个 Jquery 移动插件结合在一起。两者都使用相同的核心功能,但其中一个添加了一个选项,这使得另一个插件无法工作。
该函数的调用方式如下:
$.mobile.changePage(
url,
{
type: type && type.length && type.toLowerCase() || "get",
data: $this.serialize(),
transition: $this.jqmData("transition"),
direction: $this.jqmData("direction"),
reloadPage: true,
pageContainer:$currPanel
}
);
pageContainer 仅由一个函数使用。
我的问题: 有没有办法在选项中进行区分,或者我是否必须做这样的事情:
if (called by plugin one) {
function with option
} else if (called by plugin two){
function without option
}
必须有更好的方法来做到这一点?
I'm trying to mesh together two Jquery mobile plugins. Both are using the same core functions, but one adds one options, which keeps the other plugin from working.
The function is called like this:
$.mobile.changePage(
url,
{
type: type && type.length && type.toLowerCase() || "get",
data: $this.serialize(),
transition: $this.jqmData("transition"),
direction: $this.jqmData("direction"),
reloadPage: true,
pageContainer:$currPanel
}
);
with pageContainer only being used by one function.
My question:
Is there a way to differentiate within the options or do I have to do something like this:
if (called by plugin one) {
function with option
} else if (called by plugin two){
function without option
}
There must be nicer ways to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在调用之外对对象进行尺寸标注并测试以查看是否需要附加参数:
Dimension your object outside your call and test to see if you require the additional parameter: