[英]Modal to be opened after page reload in Ruby on Rails
In my ruby application, i want my modal to be opened after a page reload.. 在我的ruby应用程序中,我希望在页面重新加载后打开我的模式。
I have tried the follwing code... 我已经尝试了以下代码...
:javascript
$(document).ready( function() {
$(".minus").click(function(){
location.reload();
$('#memberModal').modal('show');
});
} );
Please help me with a solution.. 请帮我解决。
Thanks in advance 提前致谢
You cannot call modal after location.reload()
because the page is deconstructed. 您无法在
location.reload()
之后调用模式信息,因为该页面已被解构。
I would recommend adding not using reloading. 我建议添加不使用重新加载。
If you really want to, try adding attribute to location and open modal according to it. 如果确实需要,请尝试将属性添加到位置并根据其打开模式。
$(".minus").click(function(){
// change it according to your use case
document.location = document.location + "#memberModal";
}
$(document).ready(function(){
if (window.location.hash != null){
$(window.location.hash.substr(1)).modal('show');
}
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.