My colleague Paul and I have been discussing a feature of the jQuery library that really helps when adding events to a web page.
Historically using the click event or binding events to dynamic content could be tricky. This is because it’s possible to bind more than one event to an element. Care needs to be taken otherwise another event might be added to existing elements on the page.
The live event handler is an alternate method to bind or click, for example:
// code here
This means all current and future list items will now have this event handler bound to them. This is great because there’s no longer the need to manage bound events to new content.
Which got us arguing, what does ‘live’ stand for? Is it:
‘live’ – meaning it handles event binding on the fly as new elements are added, rather than having to call a function that binds events to the new items after finishing (think how a football match can be aired live – it’s happening in real time)
‘live’ – is an event that lives on regardless of whether content is generated or existing.
Let us know before this gets ugly! – just leave a comment below saying which of us you think is right – or even giving us your own take on it!