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


for example, call default settings on every page load , bind function loadcomplete basic formatting grids.

on pages, have additional logic execute @ same time, if set loadcomplete in grid definition, overwrite function set in defaults.

is there way bind multiple handlers, or other way of executing necessary code? in advance.

i think ask important problem existing in current version of jqgrid. it's difficult implement more 1 event handler in jqgrid now. problem not important small projects use jqgrid, can important in case want construct classes interprets jqgrid. current workaround ok, have restriction understand yourself. main problem in way can implement only one more additional loadcompleteex handler.

what suggest usage of jquery.trigger or better jquery.triggerhandler. can use jquery.bind , jquery.unbind. in way can define number of event handlers works standard jquery events.

for example,

var grid = $("#list");  grid.bind('jqgridloadcomplete',function(e,data) {     alert ("in first jqgridloadcomplete event handler. called page " +            data.page); }); grid.jqgrid({     // jqgrid parameters     // ...     loadcomplete: function(data) {         alert("main load complete");         $(this).triggerhandler("jqgridloadcomplete", data);     } }); grid.bind('jqgridloadcomplete.jqgrid',function(e,data) {     alert ("in second jqgridloadcomplete event handler. called page " +            data.page); }); 

in second jquery.bind used namespaced event 'jqgridloadcomplete.jqgrid' namespace 'jqgrid'. can use know (and need) standard events in jquery.

see corresponding demo here. try switch pages in grid or change sorting call loadcomplete.

i bind second jqgridloadcomplete after jqgrid definition. because demo uses datatype:'local' first call of loadcomplete before binding executed. @ first loadcomplete execution second jqgridloadcomplete event handler not called. should better bind event handler before jqgrid definition. in case can sure event called.

updated: important!!!. 1 don't need trigger jqgridloadcomplete event explicitly inside of loadcomplete if use current version of jqgrid. jqgrid do you. above code written before corresponding functionality included in main code of jqgrid. answer described main idea how multiple event handlers implemented in jqgrid. after writing answer posted pull requests trirand suggestion implement jquery events in jqgrid. starting version 4.3.2 (see here) jqgrid support events.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -