Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Add event listeners on column template element
posted

Hello,

I use the igGrid with a single column template like http://jsfiddle.net/yuz7LwLa/.

My problem : i can't find a way to add event listeners on element of my template.

In the jsfiddle example, i have the template :

<div style='float: left;'>
   <img width='100' height='90' src='${ImageUrl}'></img>
</div>
<div class='right' style='float: left; font-size: 1.1em;'>
   <span>Name:&nbsp;</span><span>${ProductName}</span><br/>
   <span>Category:&nbsp;</span><span>${CategoryName}</span><br/>
   <span>Units In Stock:&nbsp;</span><span>${InStock}</span><br/>
</div>

How can i add a listener in my img, after row added in DOM?

Is there an event that give the tr or the td added in the grid as parameter like

OnRowReady(grid, args) {
  var generatedRowOrCell = args.row;
  jQuery("mySelectorForFindMyImg", args.row).on("click", function() {
       console.log("Yeah! You find a way to add listener");
  }
}

I know it is possible to add onclick attribute in the template, but in my real case, the template is more complex and i need to call a class function with js closure.

Thanks for your reply

Yoann.