Is it possible to bind multiple event handlers to JqGrid events without overwriting previous ones?

前端 未结 4 2039
旧巷少年郎
旧巷少年郎 2020-11-29 10:40

For example, I call my default settings on every page load and bind a function to loadComplete to do some basic formatting for my grids.

On some pages, I have additi

4条回答
  •  时光取名叫无心
    2020-11-29 11:24

    My hackaround solution:

    // Global Variable in my common.js
    var loadCompleteEx;
    
    // set defaults
    $.extend($.jgrid.defaults, {
         datatype: 'json',
         height: "100%",
         ...
         loadComplete: function () {
             if ($("#grid").getGridParam("reccount") === 0)
                $("#empty-grid-message").show();
             else
                $("#empty-grid-message").hide();
    
             // if loadCompleteEx is defined, call it at the end of loadComplete
             if (loadCompleteEx)
                 loadCompleteEx();
          }
    }
    
    // In my specific page js
    loadCompleteEx = function () {
        // Do more stuff after load completes
    };
    

    Works like a charm...is there any bad practice in here?

提交回复
热议问题