I'm appending some code to my page using jQuery AJAX calls. This code is a mix of html and javascript. But I want javascript to be executed only when html part is ready. But what event is raised when appended html is rendered?
Here is an example:
<table id="sampleTable">
...
</table>
<script>
// this code should be executed only when sampleTable is rendered
$('#sampleTable').hide();
</script>
Use the jQuery ready() event:
$(document).ready(function() {
$('#sampleTable').hide();
}
<edit>
It seems to be impossible to call a ready event on any other object than Document, my bad </edit>
This is an option if you are talking about the event triggered after a successful Ajax request :
$('#sampleTable').ajaxComplete(function() {
$(this).hide();
});
Or just hardcode the style of the table to display:none;...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With