Hello,
i have a ajax to create a list view.
ajax add multiple line like this:
<li><a href="#" onclick="
When i click the href in list view i need to start a function
How do i do ?
Thanks.
Hello,
i have a ajax to create a list view.
ajax add multiple line like this:
<li><a href="#" onclick="
When i click the href in list view i need to start a function
How do i do ?
Thanks.
Let’s assume this happens in a page event handler, say pageInit()
:
// Somewhere in your routes definitions...
pageInit: function(event, page) {
page.$el.find('li > a').click(function (e) {
// Do something here. e.target is the element clicked
}
}
Refer to the immediate parent element that was already present first, then the dynamically created element,
$$("#parent-element").on("click", "li a", function(event) {
// Your logic
});
Hello,
i have resolved whit this cose:
self.$$(document).on("click",".class_name",function() {
// code
});
Because the dynamic element not fire event with this code:
$$("#parent-element").on("click", "li a", function(event) {
// Your logic
});
I have inserted my code in “pageInit”
Thank you @mossaiby and @bryceandy
Your code needs to be run after your new elements are added to the DOM. Anyway, I am glad you solved your problem!
Ok. i check the code and implement the new function. thanks!
You’re welcome, my friend!