RJS Templates & Safari?

Hello,

I tried Cody F. RJS tutorial
(http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates)

on my railsplayground dev site and got it to work when using Firefox,
but when I tried it on Safari, nothing happens.

Then I tried this tutorial -
http://rewrite.rickbradley.com/articles/2006/02/06/rjs-templates

Similarly, it works fine on Firefox… but with Safari the list is not
refreshed even though the background AJAX table update is successful.

I wrote to Cody F. but he said that he was not familiar enough with
Safari to venture a guess.

Railsplayground is running ruby 1.8.4 & rails 1.1.0

Any guesses? Has anyone else run into anything similar?

Randy Marmer

On 4/14/06, randy marmer [email protected] wrote:

Similarly, it works fine on Firefox… but with Safari the list is not
refreshed even though the background AJAX table update is successful.

As I noted in the comments to the second link, make sure your layout
file has this in the section:

<%= javascript_include_tag :defaults %>

I found the same thing… the scripts wouldn’t work.

jt

John T. wrote:

On 4/14/06, randy marmer [email protected] wrote:

Similarly, it works fine on Firefox… but with Safari the list is not
refreshed even though the background AJAX table update is successful.

As I noted in the comments to the second link, make sure your layout
file has this in the section:

<%= javascript_include_tag :defaults %>

I found the same thing… the scripts wouldn’t work.

jt

Ahhhh… so that was you! Thanks! Actually I did see that & included the
defaults, but I didn’t put in the head section… I went ahead & added
the necessary html, but it still won’t refresh the list in Safari. Have
you had success with this on Safari?

John T. wrote:

On 4/14/06, randy marmer [email protected] wrote:

Ahhhh… so that was you! Thanks! Actually I did see that & included the
defaults, but I didn’t put in the head section… I went ahead & added
the necessary html, but it still won’t refresh the list in Safari. Have
you had success with this on Safari?

Yeah, his sample worked fine for me with Safari.

jt

Hmmmm… The only difference seems to be the addition of the plugin… I
did not use it since railsplayground is running rails 1.1.0 which is
supposed to include RJS… Did you run it with the plugin?

On 4/14/06, randy marmer [email protected] wrote:

Hmmmm… The only difference seems to be the addition of the plugin… I
did not use it since railsplayground is running rails 1.1.0 which is
supposed to include RJS… Did you run it with the plugin?

Nope, I didn’t install the plugin either, since I had 1.1 installed too.

Have you tried choosing “Show Javascript Console” from Safari’s Debug
menu, to see if any Javascript errors are displayed (from an
unintentional mis-type)?

jt

On 4/14/06, John T. [email protected] wrote:

On 4/14/06, randy marmer [email protected] wrote:

Hmmmm… The only difference seems to be the addition of the plugin… I
did not use it since railsplayground is running rails 1.1.0 which is
supposed to include RJS… Did you run it with the plugin?

One other quick thing to check, what is the DOCTYPE of your layout
.rhtml file?

John T. wrote:

On 4/14/06, randy marmer [email protected] wrote:

Hmmmm… The only difference seems to be the addition of the plugin… I
did not use it since railsplayground is running rails 1.1.0 which is
supposed to include RJS… Did you run it with the plugin?

Nope, I didn’t install the plugin either, since I had 1.1 installed too.

Have you tried choosing “Show Javascript Console” from Safari’s Debug
menu, to see if any Javascript errors are displayed (from an
unintentional mis-type)?

jt

Yes, I tried that… nothing shows up. I also stuck a breakpoint in
there & got this:

irb(#<#Class:0x2590418:0x25903c8>):001:0> @category.errors.empty?
=> true

So I’m just puzzeled by this?

John T. wrote:

On 4/14/06, John T. [email protected] wrote:

On 4/14/06, randy marmer [email protected] wrote:

Hmmmm… The only difference seems to be the addition of the plugin… I
did not use it since railsplayground is running rails 1.1.0 which is
supposed to include RJS… Did you run it with the plugin?

One other quick thing to check, what is the DOCTYPE of your layout
.rhtml file?

I didn’t include one… What did you use?

On 4/14/06, randy marmer [email protected] wrote:

Ahhhh… so that was you! Thanks! Actually I did see that & included the
defaults, but I didn’t put in the head section… I went ahead & added
the necessary html, but it still won’t refresh the list in Safari. Have
you had success with this on Safari?

Yeah, his sample worked fine for me with Safari.

jt

John T. wrote:

On 4/14/06, randy marmer [email protected] wrote:

I didn’t include one… What did you use?

I just redid the example, and it’s working again for me (RoR 1.1.2,
Ruby 1.8.4, OS X)

My home.rhtml layout file is:

home <%= javascript_include_tag :defaults %> <%= @content_for_layout %>

Hey, thanks for hangin’ in there with me… unfortunately that didn’t
work either. Maybe I should try updating my own system with RoR 1.1.2 &
see if that makes a difference.

I may also ask the good folks at Railsplayground if they have any
ideas…

Thanks again!

On 4/14/06, randy marmer [email protected] wrote:

I didn’t include one… What did you use?

I just redid the example, and it’s working again for me (RoR 1.1.2,
Ruby 1.8.4, OS X)

My home.rhtml layout file is:

home <%= javascript_include_tag :defaults %> <%= @content_for_layout %>

John T. wrote:

On 4/14/06, randy marmer [email protected] wrote:

Hey, thanks for hangin’ in there with me… unfortunately that didn’t
work either. Maybe I should try updating my own system with RoR 1.1.2 &
see if that makes a difference.

I may also ask the good folks at Railsplayground if they have any
ideas…

Thanks again!

I don’t suppose you have Javascript turned off in Safari’s
preferences? Just a wild shot…

jt

Yeah… I honestly wish that were it… that’s the type of thing you
hate have done but love to find = simple solution to otherwise
perplexing situation…

Thanks again!

On 4/14/06, randy marmer [email protected] wrote:

Hey, thanks for hangin’ in there with me… unfortunately that didn’t
work either. Maybe I should try updating my own system with RoR 1.1.2 &
see if that makes a difference.

I may also ask the good folks at Railsplayground if they have any
ideas…

Thanks again!

I don’t suppose you have Javascript turned off in Safari’s
preferences? Just a wild shot…

jt

Tom M. wrote:
> Whenever Javascript stuff doesn’t work, try validating
> your XHTML, particularly when one browser works and
> another doesn’t.
> http://validator.w3.org/

One more reason to use Firefox: install the WebDeveloper plugin, and you
can validate local html pages with one key press
Ctrl-Shift-A

You can even validate local CSS files.

Alain

Whenever Javascript stuff doesn’t work, try validating
your XHTML, particularly when one browser works and
another doesn’t.


– Tom M.

Guest wrote:

hi there,
Put your app in production mode and I bet it works fine in Safari.
Might be the “?1144942301” junk at the end of all resource links in dev
mode that Safari doesn’t like. No idea really. But things work fine in
production.

uncomment this line in your config/environment.rb:

ENV[‘RAILS_ENV’] = ‘production’

restart your server.

try it out now.

p.s. it IS super strange though. And its annoying. And all the
scriptaculous stuff seems to be fine. weird.

FYI:

I can’t say that I get it, but I did identify rhe problem I was
having…

In the development.rb file that is created by rails 1.1, the following
line is added;

“config.action_view.debug_rjs = true”

Setting that to false worked in one dev environment, but not another
(locomotive 1.1 on the a powerbook)… In the 2nd case I had to remove
it entirely!

On 4/15/06, randy marmer [email protected] wrote:

Setting that to false worked in one dev environment, but not another
(locomotive 1.1 on the a powerbook)… In the 2nd case I had to remove
it entirely!

Ah. That’s one difference. I’m using a self-built Ruby 1.8.4 and Rails
1.1.2 (using the directions on:
http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_mysql_tiger

I then tried my install of Locomotive. It had the 1.0 rails bundle, so
I downloaded the 1.1 bundle packages.

When I tried running with that, I couldn’t even access the app, it
wouldn’t even respond. So I went to the Terminal, via Locomotive, and
did a ‘sudo gem update’ and let it update a bunch of gems, including
Rails 1.1.2.

Now, running under Locomotive, it works fine with Safari. And I didn’t
touch that config line in the development.rb file. So, try updating
your gems, and don’t forget to do a ‘rake rails:update’ too.

hth,

jt

When I tried running with that, I couldn’t even access the app, it
wouldn’t even respond. So I went to the Terminal, via Locomotive, and
did a ‘sudo gem update’ and let it update a bunch of gems, including
Rails 1.1.2.

if you have this line in your environment:
RAILS_GEM_VERSION = ‘1.1.2’
and you are running on a machine without that version (or in locomotive
without that version) you won’t get any love from your app. This would
have probably also worked fine for you: RAILS_GEM_VERSION = ‘1.1.1’.

I just mention it because its probably something a lot of people might
run into.

Thanks for the tip Randy. I was getting sick of restarting my server
with every fart.

hi there,
Put your app in production mode and I bet it works fine in Safari.
Might be the “?1144942301” junk at the end of all resource links in dev
mode that Safari doesn’t like. No idea really. But things work fine in
production.

uncomment this line in your config/environment.rb:

ENV[‘RAILS_ENV’] = ‘production’

restart your server.

try it out now.

p.s. it IS super strange though. And its annoying. And all the
scriptaculous stuff seems to be fine. weird.