EasyUI Forum
May 16, 2024, 06:32:31 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: combobox show value (but not text) after init twice  (Read 8886 times)
yulei
Newbie
*
Posts: 9


View Profile Email
« 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 ?


« Last Edit: April 12, 2015, 07:34:12 PM by yulei » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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.
Logged
yulei
Newbie
*
Posts: 9


View Profile Email
« Reply #2 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!