Note to Self
To bind an event handler for the current and future selector, use .live() method.
For instance you have:
$('.button').click(function() {
// do things.
});
This will work when the button class element is clicked. But when you add another button class element:
$('body').append('<input type="button" value="Click Here" class="button" />');
This won’t work, since it was added later by the .append() method. To get around this, use .live() method. This will work for the current and the future elements.
$('.button').live('click', function() {
// do things here.
});