3

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
  • use .live() or .delegate for the button event handling Commented May 31, 2010 at 11:08

1 Answer 1

3

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.
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.