i'm using select2 jquery plugin mvc4. have javascript file working fetching data in json in controller, i'm getting error when debug , try display results:
unable property 'touppercase' of undefined or null reference i think might have json i'm returning since looks objects or fact they're ints, i'm not entirely sure. converting them strings via tostring() didn't work either. [{"name":1,"label":1,},{"name":2,"label":2},...]
here's js:
$("#itemid").select2({ ... ajax: { url: $("#itemid").attr("data-getids"), datatype: "json", data: function (param) { return {query: param};}, results: function(data) { return {results: data};} } });
i figured out. i'm using older version of select2 (3.4.5) , ended mapping json in results function.
results: function (data) { return { results: $.map(data, function (item) { return {text: item.name, id: item.id}; }; }), }
Comments
Post a Comment