Reputation: 10030
Curious if anyone can give me an argument for using one over the other.
Example 1)
XML
<Button id="editGroupBtn" class="groupEditButton" title="Edit" />
JS
function handleEditGroupClick(e) {
//Insert Amazing Code here
}
$.editGroupBtn.addEventListener('click',handleEditGroupClick);
Example 2)
XML
<Button onClick="handleEditGroupClick" class="groupEditButton" title="Edit" />
JS
function handleEditGroupClick(e) {
//Insert Amazing Code here
}
At the moment my superior is arguing he likes the separation of concerns (view only has the view). My argument is issues with adding and removing event listeners (requires more maintenance, more code clutter, and I would assume the code is slower)
Further, the creation of the button is actually in a loop so my argument is that you also don't have to add an ID to listen if you do an onClick (Which I'm a fan of because I don't have multiples of a single ID) but there are other work arounds
Upvotes: 1
Views: 540