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?
Dimension your object outside your call and test to see if you require the additional parameter:
var myOptions = {
type: type && type.length && type.toLowerCase() || "get",
data: $this.serialize(),
transition: $this.jqmData("transition"),
direction: $this.jqmData("direction"),
reloadPage: true,
};
if (caller == someVariable ) {
myOptions.pageContainer = $currPanel;
}
$.mobile.changePage(url, myOptions);