0
我正在嘗試在關閉模式時重置/清除表單內的窗體,但這似乎不起作用。這是我的代碼:關閉時重置/清除模態窗體
<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>
有人能指導我哪些地方可以corrected.Thanks 這是小提琴鏈接
https://jsfiddle.net/qzzu2vqs/4/
仍然沒有工作。 –
堅持下來,讓我創建一個工作示例。 –
它適合你嗎? –