Reputation: 406
I’m using the last version of Framework7 (5.7).
I have this problem. I have some dynamic content in my pages, included inside the Dom with $('.element').html()
.
In order to manage the onclick()
event on this elements I use delegate in this way:
$(document).on(‘click’, ‘.favorite-icon’, function(event) {}
or
$(document).delegate(’.favorite-icon’, ‘click’, function(event) {}
The onclick()
event works good with this method, but I have a problem.
Some of this elements exist in multiple pages. So if I change page in my app and click on those elements the onclick()
event is triggered twice or more if I change multiple times page.
How can I solve this?
Upvotes: 2
Views: 113
Reputation: 1129
Try this:
$(document).undelegate('click').delegate(’.favorite-icon’, ‘click’, function(event) {}
It should eliminate all conflicts.
Upvotes: 1