javascript - jQuery-confirm 防止在 callerElement.hide() 上滚动
问题描述
我有一个问题,在我隐藏打开确认对话框的按钮元素后,我的页面滚动到顶部。
确认 doalog 关闭后,它会滚动回滚动到调用者元素。如果没有这样的元素,请改为滚动到顶部。我可以阻止那个滚动吗?
我在 js fiddle 中重新创建了我的问题: https ://jsfiddle.net/at6sLy2g/
$('#openDialog').on('click', function(){
$.confirm({
buttons: {
confirm: function () {
$('#openDialog').hide();
},
cancel: function () {
}
}
});
})
解决方案
添加以下行以确认弹出配置:
$.confirm({
scrollToPreviousElement: false, // add this line
scrollToPreviousElementAnimate: false, // add this line
buttons: {
confirm: function () {
$('#openDialog').hide();
},
cancel: function () {
}
}
});
推荐阅读
- haskell - groupBy 对不相邻元素进行分组的函数
- wordpress - 通过 Javascript 将模板分配给帖子类型
- android - 我可以访问 Google Play 音乐 MIDI 声音吗?
- python - 我可以散列一个 UUID 以获得更高的熵吗 - Python
- ethereum - 使用 Node-RED 离线签署以太坊交易
- c# - c#应用程序中的Excel工作表视图
- laravel - Traits\SimpleTree getAllChildren 方法获取数组中的重复子项
- arrays - 如何在Angular2中推入后找到数组对象的值
- c# - UWP APP 使用 Xbox 控制器代替鼠标
- mongodb - 使用 docker-compose 将我的 netcore 应用程序连接到 mongodb?