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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -