使用Twitter中的Twitter Bootstrap jquery模式链接到另一个页面

我只是希望这个模式出现并显示另一个页面的内容,但我不能让它工作,因为我是Jquery的新手。 有没有办法修改下面的代码,以便在模态弹出窗口中显示’/ contact /’的内容?

---------- # this content is on http://myurl.com/contact/  ---------- # this is the button on a 'show' page where i want someone to push to bring up the contents of the above page in the modal. Launch Email 

好的,所以这里的诀窍是“其他页面”可能是Rails控制器操作的结果,通常会将页面呈现在单独的URL上,对吧? 然而,bootstrap假设当您单击该链接时,其HTML已存在于当前页面上。

那么如何处理呢? 你需要通过AJAX发出控制器请求( link_to ... :remote => true是一个很好的起点)并更改控制器,将其内容添加到当前页面上的div中。 一旦完成,您上面的代码或类似的代码(或者类似于Bootstrap页面上记录的内容)将完成您想要的操作。

编辑:添加具体的例子,在我的情况下,在bootstrap模式中打开编辑用户页面(使用Devise gem进行身份validation):

app/views/devise/registrations/_edit.html.erb:

  

app/views/devise/registrations/edit.js.erb:

 $("#main").before("<%= escape_javascript(render "edit", :formats => [:html]) %>"); $("#user-edit").modal(); 

并且,从任何页面调用它的链接(我现在在导航中有它:

 
  • <%= link_to "Edit Account", edit_user_registration_path, :remote => true %>