This project is archived and is in readonly mode.
RJS generating raw javascript when using observe_field
Reported by Conrad Taylor | September 27th, 2008 @ 01:22 PM | in 2.x
Hi, I'm in the process of structuring a live search within an application. Thus, I have the following so far:
- search.html.erb - This file contains the entire template for the page. The relevant pieces is as follows:
<%= text_field_tag 'search_text' %>
<%= observe_field( 'search_text',
:frequency => 0.5,
:with => 'search_text',
:url => { :action => :search }) %>
- UpdateController#search - The relevant pieces is as follows:
def search
@episodes = Episode.activated.search( params[:search_text] )
render :update do | page |
page[:search_hits].replace_html :partial => 'episode', :collection => @episodes, :locals => { :display => "thumb" }
end
end
Now, when render is invoked in the search action above, I'm getting the raw Javascript code returned to the browser in a try-catch block instead of the search_hits div being updated. Lastly, I'm using Rails 2.1.1 on Mac OS X 10.5.5.
Comments and changes to this ticket
-
eknv September 29th, 2008 @ 04:12 PM
I also had the try-catch issue, my javascript codes were just displayed instead of getting executed.
Wrapping the rjs code with a javascript content-type header made it work:
page << ' '
-
Pratik January 18th, 2009 @ 05:49 AM
- Tag changed from 2.1, bug, rjs to 2.1, bug, rjs
- State changed from new to invalid
You should ask this on the mailing list - http://groups.google.com/group/r...
Thanks.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>