PNotify(http://sciactive.github.io/pnotify/)是个不错的jquery库(好像最新版的pnotify已不需要jquery了)。
使用它来实现网站常用的提示框,很方便。
但如果需要一处,就要写个十来行,还是不太方便。
刚好,django中有模板,模板中有include关键,
使用下面这个js函数,独立成一个文件。
function ShowNotice(title, text, type, delay, is_mouse_reset) { var stack = {'dir1': 'down', 'firstpos1': 25 }; PNotify.alert({ title: title, text: text, icons: 'brighttheme', styling: 'bootstrap3', type: type, hide: true, delay: delay, width: "450px", stack: stack, mouse_reset: true, modules: {} }); };
在需要调用时,include这个文件,直接调用即可。
ShowNotice('错误', '未输入搜索关键字', 'error', 1000);