模式关闭后无法在页面上滚动 [英] Cannot scroll on page after modal closes
本文介绍了模式关闭后无法在页面上滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个模态来更新数据.更新完成后,模式将关闭,之后我将无法在页面上滚动.
I have a modal to update data. When the update is complete the modal closes and I cannot scroll on the page afterwards.
模式
<div id="catupdate" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
javascript
$(document).off('click','.updatecat');
$(document).on('click','.updatecat',function(){
$('#cat-update').ajaxSubmit({
dataType:'json',
success:function(response){
if(response.type == 'success'){
$(this).hide();
//$('#catupdate').modal('hide');
$('.modal-backdrop').remove()
$('#taba4').trigger('click');
}else{
alert(response.message);
}
alert("Category Updated");
console.log(response);
}
})
});
控制器
public function updatecat(Request $request){
try{
$type ='success';
$message ='Successfully Updated';
$post = $request->all();
//$user = Auth::user()['id'];
$cat = Category:: findorFail($post['id']);
$cat->category = $request->input('category');
$cat->save();
}catch(Exception $e){
$type ='error';
$message = $e->getMessage();
}
echo json_encode(['type'=>$type,'message'=>$message]);
}
我不知道发生了什么.我在其他地方使用了相同的模式和脚本,并且在这里可以正常工作.
I don't know what is happening. I have used the same modal and script elsewhere and it works fine there.
推荐答案
在onclick行中添加
add below line in your onclick
$('body').removeClass('modal-open');
这篇关于模式关闭后无法在页面上滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文