+ 2

Does default events work on dynamically (added through code behind) added markup?

Just like in jquery, if I add markup through code behind the default events like click event or other as well don't work. then you need to add on with any event in quote in bracket need to add to make it work. So will it work in JavaScript?

5th Feb 2018, 10:47 AM
Praful Jangid
Praful Jangid - avatar
1 Antwort
0
Hi Prafal sadly you have to manually re attach events when you create them dynamically in JS. See really good article here. https://pawelgrzybek.com/cloning-dom-nodes-and-handling-attached-events/ Some Frameworks have a helper function that does this for you. here is sample code in Material Design Lite https://code.sololearn.com/W8X0jAWSy34q/#html
15th Mar 2018, 3:51 PM
Mike Choy
Mike Choy - avatar