简体   繁体   English

防止Rails重定向页面

[英]Keep Rails from redirecting a page

I'm having some trouble and I hope someone can help me. 我遇到了麻烦,希望有人能帮助我。 I have an erb file with a form in it that has a button. 我有一个带有按钮的表单的erb文件。 When you click the button it redirects the page elsewhere and shows the erb file that I told it to point to. 当您单击该按钮时,它将页面重定向到其他位置,并显示我告诉它指向的erb文件。 This is great except I'd really like to stuff the content of that directed-to erb file into a div that is sitting below my form. 很棒,除了我真的很想将指向erb文件的内容填充到位于表单下方的div中。 My view looks something like this. 我的观点看起来像这样。

<div id="formentry">
  <%= form_for @time, :url => {:action => 'list'}, :remote => true, :update => 'results' do |f|%>
  <%= select :time, :period, TimeSelectModel::TIMEVALUES %>
  <%= f.submit "Submit" %>
<% end %>
</div>

<div id="results"></div>

From what I've read online this seems like the approach you're supposed to take to do this in Rails3 but I'm not finding that it's working. 从我在网上阅读的内容来看,这似乎是您应该在Rails3中采用的方法,但是我发现它没有用。 (see: the page is completely redirecting) What am I doing wrong? (请参阅:页面完全重定向)我在做什么错? Thanks. 谢谢。

My impression from your post is that you want to submit a form and show the results without leaving the page. 我对您的帖子的印象是,您希望提交表单并显示结果而不离开页面。 What you are looking to do requires use of javascript/ajax. 您要执行的操作需要使用javascript / ajax。

Checkout railscast 205 for an example of how to do this. 检出railscast 205,了解如何执行此操作的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM