Rails AJAX ERB 查看问题 link_to_remote

发布于 2024-09-19 08:10:50 字数 1149 浏览 4 评论 0 原文

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

Rals 3.0

My question is using link_to_remote to make an ajax call.

2.3.8 Ajax call

<%= link_to_remote image_tag("../images/services_button.jpg", :mouseover => 
    "../images/services_button_over.jpg"), :url =>{:controller => :dashboard, :action => :service} %>

Current View -

<% link_to_remote view_path do %>
            About Us<span>Who we are</span>
<% end %>

How do I go about turning my current view code into an ajax call ?
I've tried something like this ...

<% link_to_remote "hello", :url=>{:controller=>:sae,:action=>:bam} do %>
            About Us<span>Who we are</span>
      <% end %>

Thanks for your help in advance.

Trying to do basic...basic.. UJS.

Very simple AJAX call to make a div go up. Though it's not working. Trying to transition from 2.3.8 to 3.0. Any help is greatly appreciated. I've googled, though I'm not able to make any sense of the jargon. :( Thanks in advance

View:

<div class="test">
  Whompa
</div>
<%= link_to 'Blind-Up', :controller=>:home,:actions=>:test, :remote =>true %>

Controller:

  def test
    render :update do |page|
      page[:test].visual_effect :blind_up
    end
  end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

濫情▎り 2024-09-26 08:10:50

Rails 3 语法现在为 <%= link_to "hello", :remote =>正确%>。网上有很多关于使用新语法进行 ajax 调用的博客文章/教程 - 我推荐 http://code.alexreisner.com/articles/link-to-remote-with-ujs.htmlhttp://blog.solnic.eu/2009/09/08/unobtrusive-javascript-helpers-in- Rails-3http:// /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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文