Ruby on rails 重定向时在rails中呈现twitter引导模式

Ruby on rails 重定向时在rails中呈现twitter引导模式,ruby-on-rails,twitter-bootstrap,modal-dialog,Ruby On Rails,Twitter Bootstrap,Modal Dialog,我有一个功能正常的模式链接,可以从我的视图中的某个页面单击: <a href="#" data-toggle="modal" data-target="#manifesto-modal">Manifesto &amp; Rules</a> 除了可以在这个页面上点击外,我希望它在重定向到这个页面时默认显示。我还没有找到一个很好的方法来从控制器或其他方面对其进行编码,但我无法想象这需要太多。感谢您的投入 根据文档,您可以使用(未经测试): 那么在你看来, <

我有一个功能正常的模式链接,可以从我的视图中的某个页面单击:

<a href="#" data-toggle="modal" data-target="#manifesto-modal">Manifesto &amp; Rules</a>


除了可以在这个页面上点击外,我希望它在重定向到这个页面时默认显示。我还没有找到一个很好的方法来从控制器或其他方面对其进行编码,但我无法想象这需要太多。感谢您的投入

根据文档,您可以使用(未经测试):

那么在你看来,

<% if flash[:manifesto_modal] %>
  // a script to display modal on document ready
<% end %>

//用于在文档就绪时显示模式的脚本

我用这个JavaScript解决了这个问题。这可能不是最好的方法,我很想听听人们对它的看法:

  if ( window.location.pathname == "/edit_profile" ) {
    $('#manifesto-modal').modal('show');
  }

像这样$(document.ready(function(){$(“#manifesto_modal”).dialog({modal:true});});我找到了这个链接,但没有成功:好吧,我发现如果我添加这个:$(“#宣言模态”).modal('show');在我的rails资产管道的主“users.js”文件中,模式弹出窗口在我的“edit_profile”页面上自动打开,正如我所希望的那样。不幸的是,它现在在每一页上都会自动打开。如何将此javascript限制为特定页面?在视图html.erb中嵌入脚本不起作用:$(document.ready(function(){$('#manifesto modal').modal('show');});记住,只有在重定向时才使用并包含脚本
  if ( window.location.pathname == "/edit_profile" ) {
    $('#manifesto-modal').modal('show');
  }