EasyUI Forum
May 03, 2024, 04:11:39 PM *
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 record is null when triggering select()  (Read 8475 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: June 09, 2014, 06:46:24 AM »

When I trigger the select() method programmatically, the onselect() fires, however the record is undefined.

If I select the combo in the browser, then the onselect() fires and the record value is set correctly.

Code:
$('#xxx').combobox({
onselect:function(record){
console.log(record.value);
}
})

$('#xxx').combobox('select','somevalue')
Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 09, 2014, 07:43:39 AM »

When you call .combobox({...}) to create the component, the data items is not loaded immediately, it may take a little while to load the data from remote server. Before loading data successfully, you call 'select' method to select a un-existing record. So the 'onSelect' event fires but the record does not exist. To solve this issue, please 'select' a record after loading data successfully.
Code:
$('#xxx').combobox({
onselect:function(record){
console.log(record.value);
},
onLoadSuccess:function(){
$(this).combobox('select','somevalue')
}
})
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #2 on: June 09, 2014, 07:50:16 AM »

Thanks, but won't this cause recursion and an endless loop ??
Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: June 09, 2014, 05:59:56 PM »

No recursion occurs when calling 'select' method in 'onLoadSuccess' event.
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!