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

Delphi change the assembly code of a running process -

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

C++ 11 "class" keyword -