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

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -