119
rated 0 times
[
120]
[
1]
/ answers: 1 / hits: 31950
/ 7 Years ago, sat, november 18, 2017, 12:00:00
I am trying to reset/clear my form inside the modal when I close it but this does not seem to work. This is my code:
<a href = #myModal data-toggle=modal data-target = #edit-modal><span class = glyphicon glyphicon-tag></span></a>
<div id=edit-modal class=modal fade role=dialog aria-hidden=true>
<div class=modal-dialog>
<div class=modal-content>
<div class=modal-header>
<button type=button class=close data-dismiss=modal>×</button>
<h4 class=modal-title>Add tags</h4>
</div>
<div class=modal-body>
<form name = form2 id = form2 method = post action = {% url 'savetag' %} class = form-inline>
{% csrf_token %}
<div class = form-group>
<input name = tag id = tag required>
<button type = submit class = btn btn-danger>Save</button>
</div>
</form>
</div>
<div class=modal-footer>
</div>
</div>
</div>
</div>
<script>
$('#edit-modal').on('hidden.bs.modal', function(e){
$(this).find('form2')[0].reset();
});
</script>
Can someone guide me on what needs to be corrected.Thanks
This is fiddle link
https://jsfiddle.net/qzzu2vqs/4/
More From » jquery