How to get a correct event target in Backbone.js View that is listen to an event of jqGrid? -


i use jqgrid backbone.js , have view represents grid. code below:

var gridview = backbone.view.extend({     initialize:     function(){         _.bindall(this);     },     beforeselectrow:function(e){         return $(e.target).is('img') ? false : true;     },     render:         function(){         var self = this;          this.$el.load(             this.collection.url + 'grid/',             function(){                 self.$jqgrid = self.$('.jqgrid');                 self.$jqgrid.on('jqgridbeforeselectrow',self.beforeselectrow);             }         );          return this;     } }); 

the grid's row can contain image. if click on image, expect grid's row not selected. listen triggered event jqgridbeforeselectrow triggered jqgrid incorrect event target. expect event target image. found similar question jqgrid not select row when clicking in particular cell , there works. wrong listener?

thanks!

i don't use backbone myself, hope understand correct. want deny selection of rows of grid if click on image inside of grid. callback beforeselectrow event handler of jqgridbeforeselectrow event. if understand correct same event handler 1 bind the following way

$("#list").bind("jqgridbeforeselectrow", function (e) {     return $(e.target).is('img') ? false : true; }); 

the event handler wrong because e.target dom of <table> element base element of grid. reason jqgridbeforeselectrow custom event of <table> element.

correct implementation be

$("#list").bind("jqgridbeforeselectrow", function (e, rowid, eventoriginal) {     return !$(eventoriginal.target).is("img"); }); 

the eventoriginal represent event object of original click event initiated "jqgridbeforeselectrow" event. think transformation of changes backbone version clear you.

the demo demonstrate result.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -