javascript - Pass data-attr in Materialize's modal (leanModal) -
i using materialize framework in rails app. have element launch modal on click:
<div data-target="modal1" class="modal-trigger" data-code="<%=code%>">lalala</div>
i want catch data-code in js , save variable. i've done following official documentation:
$('.modal-trigger').leanmodal({ ready: function() { var = $(this).attr("data-code"); }, }
the variable "a" undefined. how can pass data-attr in materialize modal? best way? thanks.
update: i'd display value of data-code in modal. code:
<div id="modal1" class="modal bottom-sheet"> <div class="modal-content"> <p>the code</p> </div> </div>
update1: solved clickon method , append data attr particular div wondering if possible pass through modal.
Comments
Post a Comment