jqhph / dcat-admin

🔥 基于 Laravel 的后台系统构建工具 (Laravel Admin),使用很少的代码快速构建一个功能完善的高颜值后台系统,内置丰富的后台常用组件,开箱即用,让开发者告别冗杂的HTML代码
http://www.dcatadmin.com
MIT License
3.81k stars 680 forks source link

请教一下,如何监听页面跳转 #2083

Closed whx closed 1 month ago

whx commented 8 months ago

我在一个数据表格页面加了一段js,我希望在跳转到别的页面的时候执行另一段js。由于是单页应用,所以常规的onbeforeunload事件不会触发,我现在的办法是在js里面监听页面特定的元素来判断是否已经跳转了页面。请教各位大佬,有没有更优雅的办法实现这一功能

PorygonCN commented 8 months ago

可以查询一下pjax的事件 其中包括点击 加载等相关事件 应该满足你的需求

qiaohs commented 8 months ago
Dcat.onPjaxLoaded(function(){
    console.log(1);
});
stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.