Here is the jsfiddle , I have used almost the same fiddle My Fiddle with Ajax and here is Matt's Stickit MultiSelect Select2 with an array but added an ajax attribute to the select config.
Clicking on the Result, the model sets an undefined attribute to the model
console.log(this.model.attributes)
result friends:[1,2,undefined].
The change event just calls the getVal function , which returns an undefined value here `getVal: function($el) { var selected = $el.find('option:selected');
if ($el.prop('multiple')) {
return _.map(selected, function(el) {
**return Backbone.$(el).data('stickit-bind-val');**
});
} else {
return selected.data('stickit-bind-val');
}
}`
I think unlike the update function which adds select options, clicking the result is not adding the option or calling the addSelectOptions function.
But when using the getVal:function($el,event,options){return $el.val(val);}
returns just the values [1,2,4].But if I have a nested collection it just returns the values not the whole object.
NEED THE WHOLE OBJECT RETURNED FROM THE AJAX CALL AND SET IT TO THE MODEL ATTRIBUTE ON SELECTION.