jquery - Can't fill text on a form inside a modal (materializecss) -
i've been trying populate form elements inside modal when opens can't seem it. been searching hours , can;t seem find proper answer.
modal:
<div id="editmodal" class="modal modal-fixed-footer"> <div class="modal-content row"> <div class="center-align"> <h4>update task</h4> <p><b>note:</b> can update task name , task type</p> </div> <form class="col s10 offset-s1" id="form" method="post"> <div class="input-field col s10 offset-s1"> <input id="edttaskname" type="text" class="validate" required> <label for="edttasknamelbl">task name</label> </div> </form> </div> <div class="modal-footer"> <a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat">agree</a> </div> </div>
i tried accessing directly:
$('#tasktable').on('click', '#editbtn', function() { $('#editmodal').modal('open'); $('#edttaskname').text('asd'); $("#edttasknamelbl").addclass('active'); });
i tried accessing child modal itself:
$('#tasktable').on('click', '#editbtn', function() { $('#editmodal').modal('open'); $('#editmodal').find("#edttaskname").text('asd'); $('#editmodal').find("#edttasknamelbl").addclass('active'); });
none of has seems work. thank can me.
not $('#edttaskname').text('asd');
try $('#edttaskname').val('asd');
for text inputs have use .val() not .text()
Comments
Post a Comment