I have problem with selected value (update form) on Select2
remote data
// I use in Meteor JS
// Template for update form
{{> afQuickField name='locationId' type="select2" options=defaultLocation select2Options=locationOptions value="0001"}}
// JS
updateTpl.helpers({
defaultLocation: function () {
return [
{label: 'Cambodia', value: '0001 '}
]
}
});
Template.registerHelper('locationOptions', function() {
return {
placeholder: "Search location",
allowClear: true,
minimumInputLength: 3,
ajax: {
data: function (params) {
return params;
},
transport: function (args) {
// Meteor method call
Meteor.call('school_listAddress', args.data, function (err, results) {
if (err) {
args.error(err);
return;
}
args.success(results);
});
},
results: function (data) {
var results = [];
_.each(data, function (result) {
results.push({
id: result.value,
text: result.label
});
});
return {results: results};
}
}
};
});
It show error Option 'ajax' is not allowed for Select2 when attached to a <select> element.
.