Reputation: 3028
I want to call this after page load:
$('#chatscroller').tinyscrollbar()
Here the #chatscroller
is the dynamically appended div block.
HTML ( Existing code block ):
<div id="onlinechatlist">
<div class="chatimage">
</div>
<div id="chatscroller">
</div>
</div>
JAVASCRIPT :
function tinyscrollbar( ) {
// some codes for scrolling the particular division
}
function appendcode ( ) {
$("#onlinechatlist").append(append above html code);
// code will appended at the last of the page
});
The problem is that when the code is appended to the end of the page,
the function ( here : tinyscrollbar()
) bound with appended code's class is not executed.
Upvotes: 2
Views: 1290
Reputation: 5220
Not sure if I really do understand your question right, but maybe this helps?
This waits for the page to load, then appends the html, then calls the tinyscrollbar function.
var chatscrollerhtml = '<div id="chatscroller">blabla</div>';
function tinyscrollbar() {
//....
}
$(document).ready( function() {
$(body).append(chatscrollerhtml);
$('#chatscroller').tinyscrollbar();
});
Upvotes: 1