Dom Not Fully Loaded?
When using jQuery document ready, i.e. $(document).ready(function() { } is there any chance that the DOM has not fully loaded yet? I am using some 3rd party tools (Telerik's grid)
Solution 1:
Try using live,
$(':input').live('change', function() {
alert('you fired!');
});
Edit
.live() is deprecated form version 1.7 and is removed since version 1.9: Instead live use on()
Solution 2:
There's no chance that the statically defined DOM in the HTML page is not loaded yet at $(document).ready()
. But, if you're using a third party library that is dynamically loading or creating HTML, there is no guarantee that the library has done it's business at the time of $(document).ready()
. In fact, it's very likely that is has not.
You have a couple options:
- You can find an event that is triggered after the third party library has created it's HTML and thus the checkboxes now exist and then use tranditional jQuery to hook up to them.
- You can use the
.live()
capabilities in jQuery to capture events for even DOM objects that don't exist yet at the time you specify that you want to hook up to them. You can read about.live()
here: http://api.jquery.com/live/. It works mostly like a normal event handler except that it only works for some events and there are some differences in how you might stop propogation.
Post a Comment for "Dom Not Fully Loaded?"