Forum: Ruby on Rails strange RJS behavior

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
14519bebfcfb3799ad56957c27d21c67?d=identicon&s=25 Chris H. (chrish)
on 2006-06-13 03:53
I used RJS extensively in my last web app with no problem.

I'm just beginning a new one and having a very odd problem.

The called method, get_names, retrieves some values from the database,
then ends:

   render :layout => false

the get_names.rjs file is rendered into Javascript, but then is just
dumped as Javascript (text) into the browser:

e.g:

try {
Element.update("this_panel", "");
new Insertion.Bottom( ... );
} catch (e) { alert('RJS error:\n\n'

Any ideas?

Thanks!
Alan Francis (Guest)
on 2006-06-13 12:22
Does the link_to_remote by any chance have an :update => 'this_panel' in
it ?  That would take the reuslt of the Ajax call and update the div.
I often make this mistake if I start with an update and replace it with
RJS.

Alan

Chris Hackel wrote:

> the get_names.rjs file is rendered into Javascript, but then is just
> dumped as Javascript (text) into the browser:
14519bebfcfb3799ad56957c27d21c67?d=identicon&s=25 Chris H. (chrish)
on 2006-06-14 02:27
Alan Francis wrote:
> Does the link_to_remote by any chance have an :update => 'this_panel' in
> it ?  That would take the reuslt of the Ajax call and update the div.
> I often make this mistake if I start with an update and replace it with
> RJS.
>
> Alan
>
> Chris Hackel wrote:
>
>> the get_names.rjs file is rendered into Javascript, but then is just
>> dumped as Javascript (text) into the browser:


Alan--no it's just this:

			<%= form_remote_tag :url => { :controller => "name", :action =>
"get_name"} %>
				<label for="name_input">Enter your name:</label>
			        <%= text_field "name_input","name", :size => 20 %>
			<%= end_form_tag %>
Matthew Margolis (Guest)
on 2006-06-14 06:42
(Received via mailing list)
Chris Hackel wrote:
>>
> 				<label for="name_input">Enter your name:</label>
> 			        <%= text_field "name_input","name", :size => 20 %>
> 			<%= end_form_tag %>
>
>
Can you paste your .rjs file?  Like Alan I have seen this before when
setting :update but since you are not doing that the problem may be in
the rjs.

Matthew Margolis
blog.mattmargolis.net
Alan Francis (Guest)
on 2006-06-14 11:38
> Can you paste your .rjs file?  Like Alan I have seen this before when
> setting :update but since you are not doing that the problem may be in
> the rjs.

One other problem might be content type.  If you copy the code from the
rjs into the action and use render :update instead, does it work there ?

http://codefluency.com/articles/2006/05/27/rails-v...

A.
Alan Francis (Guest)
on 2006-06-15 11:43
Alan Francis wrote:
>> Can you paste your .rjs file?  Like Alan I have seen this before when
>> setting :update but since you are not doing that the problem may be in
>> the rjs.
>
> One other problem might be content type.  If you copy the code from the
> rjs into the action and use render :update instead, does it work there ?
>
> http://codefluency.com/articles/2006/05/27/rails-v...
>
> A.

Also, did you remember to add the javascript tags to the layout ?

A.
This topic is locked and can not be replied to.