This question is locked. New answers and comments are not allowed.
Are the controls client objects suppose to be available during the "OnLoad" client event? From my tests they aren't available until after the load event has fired, making the event useless for many scenarios.
Take the NumericTextBox for example. The documentation (http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-numerictextbox-client-api-and-events.html) states the object can be accessed via the jQuery data store:
| var numericTextBox = $("#MyElementId").data("tTextBox"); |
Using the above code is null during the OnLoad event. The problem seems to be the "load" event is triggered in the $t.textbox function before the object has been added to the elements .data() storage.
Reading more into the documentation it states:
| events.OnLoad(() => |
| {%> |
| function(e) { |
| // "this" is the sender. In this event handler will be the numericTextBox. |
| } |
| <%}); |
However "this" is the div element that contains the TextBox not the numericTextBox object. Trying to access the object via data store once again fails (i.e. "$(this).data('tTextBox')" ) the data is still null.
To solve the problem I've moved the "load" trigger out of the $t.textbox function and into the $.fn.tTextBox function after the .data() store is loaded. Example:
| $.fn.tTextBox = function (options) { |
| // ..... |
| if (!$(this).data('tTextBox')) { |
| $(this).data('tTextBox', new $t.textbox(this, options)); |
| $t.trigger(this, 'load'); |
| } |
| }); |
| }; |
Am I completely missing the way we are suppose to work with the client objects? If so please let me know.