You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having some troule with slectOptions, more precisely with defaultOption.
I am having the following scenario, there is a select which should have defaultOption in some cases and in others not. I am using the defaultOption property as a function to determine the correct default value.
Here is an example:
defaultOption: function(){
var selectedValue = this.model.get("value");
if (!selectedValue){
return {
label: "Veuillez sélectionner une valeur",
value: ""
};
} else {
return false;
}
}
Problem is default option is still added, as if
defaultOption: { label: "", value: "" }
is applied. I could not find appropriate workaround for this, so I checked the code.
The code in question is the following:
if (selectConfig.defaultOption) {
var option = _.isFunction(selectConfig.defaultOption) ?
selectConfig.defaultOption.call(this, $el, options) :
selectConfig.defaultOption;
addSelectOptions(["__default__"], $el, option);
}
My suggestion is this change:
if (selectConfig.defaultOption) {
var option = _.isFunction(selectConfig.defaultOption) ?
selectConfig.defaultOption.call(this, $el, options) :
selectConfig.defaultOption;
//changed code
if (option) {
addSelectOptions(["__default__"], $el, option);
}
}
If you guys, can help me out with an appropriate workaround or feedback for the proposed change I would appreciate it.
Thanks
The text was updated successfully, but these errors were encountered:
Hello there,
I am having some troule with slectOptions, more precisely with defaultOption.
I am having the following scenario, there is a select which should have defaultOption in some cases and in others not. I am using the defaultOption property as a function to determine the correct default value.
Here is an example:
Problem is default option is still added, as if
is applied. I could not find appropriate workaround for this, so I checked the code.
The code in question is the following:
My suggestion is this change:
If you guys, can help me out with an appropriate workaround or feedback for the proposed change I would appreciate it.
Thanks
The text was updated successfully, but these errors were encountered: