首页 > 代码库 > flexigrid的处理函数使用闭包传递this对象
flexigrid的处理函数使用闭包传递this对象
很多时候,process函数都需要获得this对象,然后调用一些方法。
下面举个例子:
config : function (groupName, description, deviceNumber, del) { var ob = this; $("#groups").flexigrid( { dataType: ‘json‘, width: 870, height: 300, colModel : [ { display: groupName, name: ‘groupName‘, width: 200, sortable: true, align: ‘left‘, process: (function (ob, hdl) { return function (celDiv, id) { hdl(ob, celDiv, id); }; }(ob, ob.editName)) }, { display: description, name: ‘description‘, width: 469, sortable: true, align: ‘left‘, process: (function (ob, hdl) { return function (celDiv, id) { hdl(ob, celDiv, id); }; }(ob, ob.editDescription)) }, { display: deviceNumber, name: ‘deviceNumber‘, width: 110, sortable: true, align: ‘left‘ }, { display: del, name: ‘del‘, width: 25, sortable: true, align: ‘left‘, process: (function (ob, hdl) { return function (celDiv, id) { hdl(ob, celDiv, id); }; }(ob, ob.remove)) } ] } ); $.ajaxSetup({ cache: false }); },
flexigrid的处理函数使用闭包传递this对象
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。