我使用的是Rails 2.3.8。
在我的application.rhtml中,我有:
<%= javascript_include_tag "jquery.js"%>
在我的index.rhtml中使用application.rhtml作为布局我有:
<div id="search_residential"> <%= link_to "Residential",
"javascript:residentialSearchForm()", :onclick=> remote_function(:url => {:propertyType => 'residential', :controller => 'site', :action => 'searchform'}, :update => 'search_form', :method => :get)%></div>`
在我应该渲染的部分中,我有:
<%logger.debug "Residential Form Partial Rendered"%>
当我点击链接时,我的日志输出:
Processing SiteController#searchform (for 127.0.0.1 at 2012-10-05 11:11:02) [GET]
Parameters: {"controller"=>"site", "propertyType"=>"residential", "action"=>"searchform", "authenticity_token"=>"Iw3ID/4Lh5IReUwOnhhSUXfn2IIVUnYpqG1N7DE4BHg="}
Rendering site/searchform
Residential Form Partial Rendered
Rendered site/searchbar/_search_residential (5.2ms)
Rendered site/searchbar/_search_form (5.9ms)
Completed in 9ms (View: 7, DB: 0) | 200 OK [http://localhost/site/searchform?propertyType=residential&authenticity_token=Iw3ID%2F4Lh5IReUwOnhhSUXfn2IIVUnYpqG1N7DE4BHg%3D]
但网站上没有显示任何内容。如果我删除了jQuery的include,则渲染部分。
答案 0 :(得分:0)
remote_function是一个原型助手,取决于prototype.js Jquery在$ namespace处会有冲突。建议不要使用原型助手。 或者您应该以noConflict模式初始化jquery。