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

jQuery data() is null/empty/not available at DomReady

0 Answers 27 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.
Derek Hunziker
Top achievements
Rank 1
Derek Hunziker asked on 02 Sep 2010, 11:28 PM
Hi all,

Just thought I would share that access to the data() object of all the components does not appear to be available at DomReady. This is likely due to the fact that the Telerik scripts are loaded at the end of the page or the data() object is initialized AFTER DomReady (please correct me if I'm wrong here).

I discovered this while trying to run a client function on DomReady that accessed some NumericTextBox values.

The workaround is to just use window.load() instead:

// Works
$(window).load(function () {
    var $data = $('#MyNumericTextBox').data('tTextBox');
    alert($data.value);
});
 
// Does not work
$(function () {
    var $data = $('#MyNumericTextBox').data('tTextBox');
    alert($data.value);
});
Tags
General Discussions
Asked by
Derek Hunziker
Top achievements
Rank 1
Share this question
or