delegate
delegate copied to clipboard
e.stopPropogation not work
Hello! Thanks a lot for module!
I have code how:
delegate('.container', '.item', 'click', (e) => {
// some actions
});
delegate('.container', '.link', 'click', (e) => {
e.preventDefault();
e.stopPropagation();
// some actions
});
And html:
<div class="container">
<div class="item">
<a href="#" class="link">click 1</a>
</div>
<div class="item">
<a href="#" class="link">click 2</a>
</div>
<div class="item">
<a href="#" class="link">click 3</a>
</div>
</div>
And when I click on the link the parent clickItem function fires
Hello! Thanks a lot for module!
I have code how:
delegate('.container', '.item', 'click', (e) => { // some actions }); delegate('.container', '.link', 'click', (e) => { e.preventDefault(); e.stopPropagation(); // some actions });And html:
<div class="container"> <div class="item"> <a href="#" class="link">click 1</a> </div> <div class="item"> <a href="#" class="link">click 2</a> </div> <div class="item"> <a href="#" class="link">click 3</a> </div> </div>And when I click on the link the parent clickItem function fires
I know that jquery will not have this problem. Have you solved this problem? I prefer to use javascript to solve this problem