views:

44

answers:

1

Hi all, I am working on a feature like status message update.. the user can update is status message without page refresh and the new message will be displayed once the user clicks the button and the other users can comment on the status message. The problem I am facing is, when the user submits the data, the new status message will be displayed and when I click the comment button the comment box is showing, but when I reload the page and click comment button the comment box is displaying...

+1  A: 

When you bind the event, the ajax result html isn't there yet.
jQuery has a simple way of dealing with this: Use live (or delegate on 1.4.2).

For example (from the above links):

instead of:

$('.clickme').click(function() {
  // Bound handler called.
});

write:

$('.clickme').live('click', function() {
  // Live handler called.
});
Kobi
thanks kobi, it works fine now... :D
Suresh