dataType: 'json',
parse: function(data) {
var rows = [];
if(data == null || data.customerList == null){
return rows;
}
for(var i=0; i<data.customerList.length; i++){
rows[rows.length] = {
data:data.customerList[i], //下拉框显示数据格式
value:data.customerList[i].cusName, //选定后实际数据格式
result:data.customerList[i].cusName //选定后输入框显示数据格式
};
}
return rows;
},
formatItem: function(row, i, max) {
return "<span style='width:40%' class='col-1'>" + row.cusCode + "</span> " + "<span style='width:58%' class='col-2'>" + row.cusName + "</span>";
},
formatMatch: function(row, i, max) {
return row.cusCode+row.cusName;
},
formatResult: function(row) {
return row.cusName;
}
}).result(function(e,data,value,sec){/**加选中后的回调函数**/
clearCustomerInfo();
$("#customerShortName").val(data.cusAbbName);
$("#customerFullName").val(data.cusName);
$("#customerCode").val(data.cusCode);
$("#licensecode").val(data.licensecode);
/*根据选择的客户、账套加载 对应产品线、收付款协议、账期*/
setPLAndPCAndCP(data.cusCode);
}).bind("unmatch", function(){
clearCustomerInfo();
});
}
其实做的只有三步:
1. 在options中添加一个onBegin的参数
2. 在onChange中判断onBegin是否有赋值,如果有,则调用这个函数,返回将返回值合并到options中去
3. 调用的时候,在onBegin函数中添加一些业务逻辑,并可以重新设置options
就这样,我们不仅可以达到动态去添加extraParams参数,而且还可以动态地修改其它options参数,这个onBegin在用户改变输入框的值就会触发。
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery窗口操作技巧总结》、《jQuery拖拽特效与技巧总结》、《jQuery常用插件及用法总结》、《jquery中Ajax用法总结》、《jQuery表格(table)操作技巧汇总》、《jQuery扩展技巧总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》
希望本文所述对大家jQuery程序设计有所帮助。










