首页  >  文章  >  web前端  >  bootstrap的缓存怎么处理

bootstrap的缓存怎么处理

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼原创
2019-07-13 16:01:072248浏览

bootstrap的缓存怎么处理

第一步进行新增验证

1563004441(1).png

第二步进行修改模态框 验证信息没有消除 且表单数据被缓存

1563004463(1).png

相关推荐:《bootstrap入门教程

模态框代码:新增修改共用一个模态框

<!-- 模态框(Modal) -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
×
</button>
<h4 class="modal-title" id="myModalLabel">
标题
</h4>
</div>
<div class="modal-body">
<form id="form1" class="form-horizontal" role="form">
<input type="hidden" id="unitId" name="unitId"/>
<div class="form-group">
<label class="control-label col-sm-2" for="">单位名称</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="unitName" name="unitName">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" >关闭</button>
<button type="button" class="btn btn-primary" onclick="save()">提交</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>

js代码   

//验证设置
 
$(function(){
$("#form1").bootstrapValidator({
feedbackIcons: {
 valid:"glyphicon glyphicon-ok",
 invalid:"glyphicon glyphicon-remove",
 validating:"glyphicon glyphicon-refresh"
 },
fields : {
"unitName" : {
 
validators : {
notEmpty : {
message : &#39;单位名称不能为空&#39;
}
}
}
}
});
});
 
  //重置表单数据
$(function() {
 $("#myModal").on(&#39;hide.bs.modal&#39;,function() {
 //关闭后重置表单数据
 $("#form1").data(&#39;bootstrapValidator&#39;).resetForm();
 
 
 });
  
 $("#myModal").on(&#39;show.bs.modal&#39;,function() {
 //打开前重置表单数据
 $("#form1").data(&#39;bootstrapValidator&#39;).resetForm();
 });
});
function save() {
 
  //保存前开启验证
$("#form1").bootstrapValidator("validate");
if($("#form1").data("bootstrapValidator").isValid()){
$.ajax({
url : "${path}/center/unit/save.action",
data : $(&#39;#form1&#39;).serialize(),
type : "post",
dataType : "json",
beforeSend : function() {
// loading show
},
success : function(result) {
if (result.success) {
search();
alert(result.message);
 
     //关闭模态框
$(&#39;#myModal&#39;).modal(&#39;hide&#39;);
} else {
alert(result.message);
}
},
complete : function() {
},
error : function(data) {
alert("error");
}
});
}}

最终解决效果

1563004495(1).png

1563004517(1).png

以上是bootstrap的缓存怎么处理的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn