由网友(转身,泪倾城)分享简介:我在做什么毛病下面的Ajax请求......?what am I doing wrong with the following Ajax request...? true %>...
我在做什么毛病下面的Ajax请求......?
what am I doing wrong with the following Ajax request...?
<%= link_to 'Business Analysis', it_business_analysis_path, :remote => true %>
的路线:
match 'it/business_analysis' => 'informationtechnology#business_analysis', :as => :it_business_analysis
控制器:
class InformationtechnologyController < ApplicationController
def business_analysis
render :update do |page|
page.replace_html 'page_content', :partial => 'business_analysis'
end
end
end
的看法:
<div id="page_content">
</div>
的部分被称为:
_business_analysis.html.erb
的错误:
Action Controller: Exception caught
<h1>Template is missing</h1>
<p>Missing template informationtechnology/update, application/update with {:formats=>[:js, "application/ecmascript", "application/x-ecmascript", :html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :handlers=>[:builder, :coffee, :erb], :locale=>[:en, :en]}. Searched in: * "/home/<user_name>/Websites/<project_name>/app/views"
看来Rails是寻找一个名为更新的看法 - 为什么?如何解决这个问题
It seems Rails is looking for a view called "update" - why and how do I fix this?
非常感谢! 汤姆
推荐答案
好了,任何人具有类似isssue,我找到了解决办法:
Ok, for anybody having a similar isssue, I found the solution:
的问题是,在Rails3,原型置换与jQuery。为此以下code是不再有效:
The problem is that, in Rails3, Prototype was replaced with jQuery. Therefor the following code is no longer valid:
render :update do |page|
page.replace_html 'page_content', :partial => 'business_analysis'
end
下面的2个链接会解释如何处理jQuery的细节:
The following 2 links will explain the details on how to deal with jQuery:
轨道3:简单AJAXy页面更新
http://railscasts.com/episodes/205-unobtrusive-javascript
汤姆
相关推荐
最新文章