Rails turbolinks breaking pnotify

心已入冬 提交于 2019-12-06 08:51:20

I've had the same issues, but that happens because PNotify loses its context, as you can see in that line the plugin assign the context as $('body'), but when you navigate using turbolink, the body is replaced so the context is lost.

What you need to do?

You need to assign the context in turbolink's event 'page:load'

$(document).on('page:load',function(){
	PNotify.prototype.options.stack  = {
		dir1: "down",
		dir2: "left",
		push: "bottom",
		spacing1: 25,
		spacing2: 25,
		context: $("body")
    }
        
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!