EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: devnull on June 09, 2014, 06:46:24 AM



Title: combobox record is null when triggering select()
Post by: devnull 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')


Title: Re: combobox record is null when triggering select()
Post by: stworthy 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')
}
})


Title: Re: combobox record is null when triggering select()
Post by: devnull on June 09, 2014, 07:50:16 AM
Thanks, but won't this cause recursion and an endless loop ??


Title: Re: combobox record is null when triggering select()
Post by: stworthy on June 09, 2014, 05:59:56 PM
No recursion occurs when calling 'select' method in 'onLoadSuccess' event.