This is a migrated thread and some comments may be shown as answers.

attaching event handling to classes within templates

1 Answer 44 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 24 Nov 2012, 03:25 PM
is there any reason why this wouldn't result in a console log upon clicking of the link?

$(".woot").click(function() {
console.log('test');
});

{field: "id", title: "id", template: "<a href='javascript:;' class='woot' id='#= id #' />#= id #</a>"},

1 Answer, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 27 Nov 2012, 06:52 AM
Hello Phil,

I suspect that at the moment this handler is wired for element with class woot, those element does not exist yet.

It will be better if you are using jQuery.on with selector that class. For example:
$(container).on("click", ".woot", function() {
    console.log('test');
 });
 
//where container is the grid instance.element


Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Phil
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Share this question
or