Rails AJAX ERB 查看问题 link_to_remote
Rals 3.0
我的问题是使用 link_to_remote 进行 ajax 调用。
2.3.8 Ajax 调用
<%= link_to_remote image_tag("../images/services_button.jpg", :mouseover =>
"../images/services_button_over.jpg"), :url =>{:controller => :dashboard, :action => :service} %>
当前视图 -
<% link_to_remote view_path do %>
About Us<span>Who we are</span>
<% end %>
如何将当前视图代码转换为 ajax 调用? 我已经尝试过这样的事情...
<% link_to_remote "hello", :url=>{:controller=>:sae,:action=>:bam} do %>
About Us<span>Who we are</span>
<% end %>
提前感谢您的帮助。
尝试做基本的...基本的..UJS。
非常简单的 AJAX 调用即可使 div 上升。虽然它不起作用。尝试从 2.3.8 过渡到 3.0。非常感谢任何帮助。我用谷歌搜索过,尽管我无法理解这些行话。 :( 提前致谢
查看:
<div class="test">
Whompa
</div>
<%= link_to 'Blind-Up', :controller=>:home,:actions=>:test, :remote =>true %>
控制器:
def test
render :update do |page|
page[:test].visual_effect :blind_up
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Rails 3 语法现在为
<%= link_to "hello", :remote =>正确%>
。网上有很多关于使用新语法进行 ajax 调用的博客文章/教程 - 我推荐 http://code.alexreisner.com/articles/link-to-remote-with-ujs.html,http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in- Rails-3 和 http:// /www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/ 作为一个很好的起点。希望有帮助!The Rails 3 syntax is now
<%= link_to "hello", :remote => true %>
. There's quite a few blog posts/tutorials online about making ajax calls with the new syntax - I'd recommend http://code.alexreisner.com/articles/link-to-remote-with-ujs.html, http://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in-rails-3 and http://www.simonecarletti.com/blog/2010/06/unobtrusive-javascript-in-rails-3/ as a good starting point. Hope that helps!