EasyUI Forum

General Category => General Discussion => Topic started by: yulei on April 12, 2015, 07:27:22 PM



Title: combobox show value (but not text) after init twice
Post by: yulei on April 12, 2015, 07:27:22 PM
for example , use the file in easyui release demo :jquery-easyui-1.4.2/demo/combobox/basic.html
I want to register an event for the commbox,
but I don't want to write any javascript code in html element's markup like : data-options='onChange:function(){...}'
so I write code like this:

Code:

$(document).ready(function() {

$('#state').combobox({
onChange:function(){
console.log('ok');
}
});
});


then , the combobox show the selected option's value 'AK',but not 'Alaska'。

dose the combobox can't be init twice ?

(http://i2.tietuku.com/ecd16a8c560a6992.jpg)


Title: Re: combobox show value (but not text) after init twice
Post by: stworthy on April 12, 2015, 08:13:18 PM
The <select> element with 'easyui-combobox' will be auto parsed when the page is ready. Please notice that you call $('#state').combobox({...}) statement again to re-create the combobox. To solve this issue, remove the 'easyui-combobox' class from the <select> element.


Title: Re: combobox show value (but not text) after init twice
Post by: yulei on April 12, 2015, 11:23:01 PM
is there any way to bind event Listener after parse?
the basic reason is :
I want to use markup style to init combobox,it make javascript code clear,
but i don't want to  write javascript code in markup, it makes html dirty.

so i want to bind onChange event after parse in javascirpt.