3
我想URL表單頁面(遠程)裝入模式,它工作得很好。但jquery驗證表單加載只是一次工作。當我再次加載的形式,不執行jQuery驗證,除了我刷新頁面。爲什麼要那樣。我的代碼有什麼問題。jQuery驗證的引導模態工作不正常
<script type="text/javascript">
$(document).ready(function(){
$('[data-toggle="modal"]').click(function() {
var url = $(this).attr('href').replace(/\s/g,"+");
if (url.indexOf('#') == 0) {
$(url).modal('open');
}else {
$.get(url, function(data) {
$(data).modal();
}).success(function() {
$('input:text:visible:first').focus();
$("#frmAddMcb").validate({
submitHandler: function(form){
$('#modalAddMcb').modal('hide');
return postForm(form, "savemcb", "Body", "listmcb", false, false);
}
});
});
}
});
});
</script>
<div class="row-fluid">
<a href="addmcb" data-toggle="modal" class="btn btn-warning btn-xs link_href" title="Add MCB">Add MCB</a>
addmcb將此表格
<div id="modalAddMcb" class="modal">
<div class="modal-dialogg">
<div class="modal-content">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
<h4 class="modal-title">Add MCB</h4>
</div>
<div class="modal-body">
<form id="frmAddMcb" enctype="multipart/form-data" class="form-horizontal" novalidate>
<div class="form-group">
<label class="col-md-2 col-sm-2 control-label">Name *</label>
<div class="col-md-9">
<input type="text" name="mcb.name" class="form-control" value='<s:property value="%{mcb.name}"/>' required>
</div>
</div>
<div class="form-group">
<label class="col-md-2 col-sm-2 control-label">Image *</label>
<div class="col-md-9">
<input type="file" name="fileUploaded" class="form-control">
</div>
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
<button class="btn btn-primary" id="submit" type="submit"> Save</button>
</div>
</form>
</div>
</div>
</div>
我有一個類似的問題,但不要有一個解決方案呢。 – plocks