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

[Solved] Subscribing to events with Javascript

2 Answers 83 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 09 Feb 2011, 12:28 AM
The documentation tells how to subscribe to client events using a C# method on the server:

.ClientEvents(events => events.OnLoad("Grid_onLoad"))

But I've got a need to subscribe through Javascript, as the handlers won't be on an immediately accessible object. How do you do this?

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 09 Feb 2011, 08:23 AM
Hello David,

I think subscribing to the onLoad event from client-code will not work as it fires very early (during document.ready()). Still you can try this:

$("#Grid").bind("load", function(e) {
   alert("1");
});


You can bind to all events like this except to OnRowDataBound. As an optimization we are raising it only when subscribed from the server side. 

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
David
Top achievements
Rank 1
answered on 09 Feb 2011, 05:45 PM
Thanks. I was able to hook in early enough to get the load event to fire. It's also worth noting that the name of the event in this case is lower camel-cased: load, dataBinding, etc.
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
David
Top achievements
Rank 1
Share this question
or