当前位置:首页>>问题

fastadmin 列表页编辑弹窗点击确定或者关闭弹窗自动刷新列表页

找到页面对应的js文件$(function(){//事件委托监听动态生成的关闭按钮&nb

admin

image.png

image.png

image.png


找到页面对应的js文件

        $(function(){
                // 事件委托监听动态生成的关闭按钮
                $(document).on('click', '.layui-layer-close', function(){
                    // 判断是否是当前页面的弹窗(避免影响其他弹窗)
                    var layerIndex = $(this).parent().attr('times');
                    var currentLayer = parent.layer.getFrameIndex(window.name);
                    
                    if (layerIndex == currentLayer) {
                        console.log('X按钮被点击');
                        // 执行你的操作
                        setTimeout(function(){
                            window.location.reload();
                        }, 300); // 加延迟确保弹窗已关闭
                    }
                });
            });  

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            
           //var index = parent.layer.getFrameIndex(window.name);//获取子窗口索引
           //parent.layer.close(index);//关闭当前页
           ////此处的这个parentId为父页面数据列表处的那个table的id,且注意父页面一定要定义了table
           //window.parent.location.reload();
            
            document.querySelector('form').addEventListener('submit', function(event) {
                //alert();
                window.parent.location.reload();
                // 如果不需要提交表单到服务器,可以阻止默认提交行为:
                event.preventDefault();
            });
            document.querySelector('form').addEventListener('reset', function(event) {
                //alert();
                window.parent.location.reload();
                // 如果不需要提交表单到服务器,可以阻止默认提交行为:
                event.preventDefault();
            });
            
            Controller.api.bindevent();
            
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }



返回顶部