Forum: Ruby on Rails RJS show as 'try...' in AJAX update

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.
86ebe25f8e39ac37357fd2142f550b0f?d=identicon&s=25 Xin Zheng (wackimonki)
on 2008-11-07 18:18
Hi guys,

I am trying to display Javascript code after an Ajax call. It is
executing the JS code, but it's also displaying it. It shows as:

try {
alert(...);
} catch ..
...

my controller code:

render :update do |page|
  page.alert message_var
end

my Javascript code:
  new Ajax.Updater("div_id", my_controller_url,
     {  asynchronous: true,
        evalScripts:  true,
        method:       'get',
        parameters:   query_string
      }
  );

In the prototype documentation, it says AJax.Updater's evalScripts will
eval anything in <script> tags, and they will not be displayed. Is there
anyway to wrap RJS output's in <script> tags?

Or another way of solving this?

Much thanks
Xin
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-07 18:26
(Received via mailing list)
On 7 Nov 2008, at 17:18, Xin Zheng wrote:

>
>        method:       'get',
>        parameters:   query_string
>      }
>  );
>
> In the prototype documentation, it says AJax.Updater's evalScripts
> will
> eval anything in <script> tags, and they will not be displayed. Is
> there
> anyway to wrap RJS output's in <script> tags?
>
Don't use Ajax.Updater with render :update (just plain old
Ajax.Request will do fine)

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