The processing function of flexigrid uses closures to pass this object.

Source: Internet
Author: User

The processing function of flexigrid uses closures to pass this object.

In many cases, the process function needs to obtain the this object and then call some methods.

The following is an example:

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 });},


In this way, the problem of not passing additional parameters can be solved perfectly.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.