I have plugged autocomplete after in initialize function as advised from stickit documentation.
Almost hello world world example:
MyApp.Views.Form = Backbone.View.extend({
el: "#my-form",
bindings: {
"#postcode_with_suburbs": {
observe: "postcode",
initialize: function($el, model, options) {
$el.autocomplete({
source: [ "c++", "java", "php", "coldfusion", "javascript", "asp", "ruby" ]
})
},
onSet: function(val, options) {
return $("#postcode_with_suburbs").val();
}
},
},
events: {
"click #form-submit" : "submit",
},
initialize : function() {
this.listenTo(this.model, "change");
this.render();
},
render: function() {
this.$el.html(JST['backbone/templates/car_insurance/form']);
this.stickit();
return this;
}
});
So the problem is whenever a user fills the form and autocomletes the postcode by clicking the autocomplete value it is not saved to the model attribute. Saved as ja instead of java

However scrolling down with a keyboard over the options from an autocomplete, the values is set properly to the attribute of a model. Saved as java