Reputation: 49
hello i have this problem where i need to append a href tag with materialize modal inside it so this is the code
<a href='#modalcreatechecklistitem' class='modal-trigger'>Add an item</a>
i have no problem when i just put it in my html however, when i tried to append using jquery
$("#ajaxChecklist").append("<a href='#modalcreatechecklistitem' class='modal-trigger'>Add an item</a>");
it is not working
UPDATE : class modal-trigger is not loaded, is this from jquery or my css? it is working fine when i code in my html file
ANSWER:
jquery doesnt allow you to append a materialize class to an element.
To do this action, you need to re-initialize the materialize element or function
in this case, i did a function on the #modalcreatechecklistitem
the funtion will re-intialize the materialize modal and open the modal
Upvotes: 0
Views: 267
Reputation: 65
Two important questions:
1 - Is it code running in document.ready
?
2 - Is there element with this id ajaxChecklist
on the page?
Upvotes: -1
Reputation: 2201
you working is working fine, i just checked in fiddle also
https://jsfiddle.net/jvk3/8nfbxa1p/1/
may be you placed inside the table div or similar to parent
Upvotes: 0