-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
I found a problem while reading plugin's options.
Calling the option method to read an option, like this:
var effects = $wizard.jWizard('option', 'effects');
It returns nothing.
The implementation of the option method in the plugin is the following:
option: function (key, value) {
if (this._superApply) {
this._superApply(arguments);
} else {
if (arguments.length < 1 || key.indexOf(".") === -1) {
$.Widget.prototype.option.apply(this, arguments);
} else {
var current = this.options,
path = key.split("."),
len = path.length - 1;
$.each(path, function (x, part) {
if (x >= len) {
current[part] = value;
} else {
current = current[part];
}
});
this._setOption(path[0], value);
}
}
},
Please note the call to superApply.
On third line, when it calls the superApply method "this._superApply(arguments)", it obviously doesn't return the option value in case of an option read (i.e. a call with only the key argument, and not the value argument).
It works correctly while setting an option.
I think the the implementation should be the following:
option: function (key, value) {
if (this._superApply) {
return this._superApply(arguments);
} else {
if (arguments.length < 1 || key.indexOf(".") === -1) {
$.Widget.prototype.option.apply(this, arguments);
} else {
var current = this.options,
path = key.split("."),
len = path.length - 1;
$.each(path, function (x, part) {
if (x >= len) {
current[part] = value;
} else {
current = current[part];
}
});
this._setOption(path[0], value);
}
}
},
So that the returned valued is returned back to the calling function.
Thank you for your work!
Best regards,
Marco
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels