I was using Selectize.js in a select box, What i need is, if an item is not in the list of options i would need to add a new item. When new item is added, i want to have an ajax
Thanks a lot, @Corgalore. Its working for me like
$(function(){
$('#desig').selectize({
create:function (input, callback){
$.ajax({
url: "url(null, array('controller' => 'employee-detail', 'action' => 'add-new-desig-ajax'));?>",
type: 'POST',
data:{'designation':input},
success: function (result) {
if (result) {
// console.log('sdfasf',result);
callback({ value: result.id, text: input });
}
}
});
}
});
});