jQuery easyui combobox cascade and trigger events, combobox cascade
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
Sweet Potato Yao December 29, 2016 09:02:09 Thursday
http://fanshuyao.iteye.com/
First, the cascading code:
$("#drawCode").combobox({ onChange : function(newValue, oldValue){ if(isEmpty(newValue)){ $('#repayPalnCodePrincipal').combobox("loadData", []); $('#repayPalnCodeInterest').combobox("loadData", []); }else{ $('#repayPalnCodePrincipal').combobox({ url : basePath + '/getListDrawRepayPaln?repayType=1&drawId='+newValue, valueField : 'repayPalnId', textField : 'repayPalnCode', onLoadSuccess : function(){ var repayPalnId = "${paymentDraw.repayPalnId}"; if(!isEmpty(repayPalnId)){ $(this).combobox("setValue", repayPalnId); } } }); $('#repayPalnCodeInterest').combobox({ url : basePath + '/getListDrawRepayPaln?repayType=2&drawId='+newValue, valueField : 'repayPalnId', textField : 'repayPalnCode', onLoadSuccess : function(){ var repayPalnId = "${paymentDraw.repayPalnId}"; if(!isEmpty(repayPalnId)){ $(this).combobox("setValue", repayPalnId); } } }); } } });
2. How to trigger the onchange event in jquery combobox?
jQuery uses $("#xxxx").change(); to actively trigger the onchange event, but not in easyui.
After testing, the onchange event of easyui can be triggered by assignment, as follows:
$("#drawCode").combobox("setValue", '${paymentDraw.drawId}');
It should be noted that you cannot directly add value to the data-options in the combobox: 'xxxxx' is directly assigned, so that the onchange event will not be triggered.
The second combobox is loaded and assigned through the onLoadSuccess event:
$('#repayPalnCodePrincipal').combobox({ url : basePath + '/getListDrawRepayPaln?repayType=1&drawId='+newValue, valueField : 'repayPalnId', textField : 'repayPalnCode', onLoadSuccess : function(){ var repayPalnId = "${paymentDraw.repayPalnId}"; if(!isEmpty(repayPalnId)){ $(this).combobox("setValue", repayPalnId); } } });
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.
Sweet Potato Yao December 29, 2016 09:02:09 Thursday
http://fanshuyao.iteye.com/