javascript - select2 - json data not showing -
javascript - select2 - json data not showing -
html:
<div> <input type="hidden" style="width:300px" id="search"/> </div>
javascript:
<script> $(document).ready(function(){ $('#search').select2({ data:[{id:1,text:'hello'},{id:2,text:'select2'}] }); }); </script>
result:
select2 version: 3.5.1
your object malformed -
{ data:[{id=1,text='hello'},{id=2,text='select2'}] }
should be
{ data:[{id:1,text:'hello'},{id:2,text:'select2'}] }
javascript html jquery-select2
Comments
Post a Comment