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
Added ajax config in select2 config , on selecting the result, the added model attribute is undefined .
Here is the fiddle http://jsfiddle.net/atummala/40rwfybf/
On click of save the model attributes are logged.
The text was updated successfully, but these errors were encountered:
I don't think anyone is still maintaining this library, but I ran into this issue recently and when I got to the bottom of it turns out it's because stickit sets a jQuery data property called 'stickit-bind-val' in each option tag that it creates or processes and uses that to read back the value when the option is selected. But when select2 creates option tags from your selection it doesn't set that data property (why would it), so stickit has nothing to read back.
In our codebase, I overrode this by modifying the getVal method for 'select' types to check the actual value of the option tag as a fallback if the stickit-bind-val data property isn't set. I can make a pull request if anyone is still around to accept it and agrees that this should be the default behavior.
Here's the snippet:
let selectHandler = _.find(Backbone.Stickit._handlers,(h) => {
return h.selector === 'select';
});
selectHandler.getVal = function($el) {
var selected = $el.find('option:selected');
if ($el.prop('multiple')) {
return _.map(selected, function(el) {
let stickitVal = Backbone.$(el).data('stickit-bind-val');
if (stickitVal !== undefined) {
return stickitVal;
} else {
return Backbone.$(el).val();
}
});
} else {
let stickitVal = selected.data('stickit-bind-val');
if (stickitVal !== undefined) {
return stickitVal;
} else {
return selected.val();
}
}
};
Added ajax config in select2 config , on selecting the result, the added model attribute is undefined .
Here is the fiddle http://jsfiddle.net/atummala/40rwfybf/
On click of save the model attributes are logged.
The text was updated successfully, but these errors were encountered: