Guille San wrote:
> Hi everyone:
>
> I probe to use the function that Frederick says, but it doesn´t work
> because mi image don´t load the new periodical image. Where I´m doing
> something wrong??
>
> <script type="text/javascript">
>
> function lastSpy() {
>
> var target = $('imagen');
>
> if (!target) return false;
> new Ajax.PeriodicalUpdater(target,
> 'http://localhost:3000/',{frequency:'1'})
>
> }
> Event.observe(window, 'load', lastSpy, false);
> document.observe("dom:loaded", function() {
>
> $$('imagen').invoke('hide');
This is what you're saying, "Search using CSS selector 'imagen' for all
<imagen> tags and invoke 'hide' on each." This tag does not exist in
your DOM.
I assume what you want is to find the element with id='imagen' and hide
it. That would be:
$('imagen').hide();
> });
>
> </script>
> <div id="imagen" >
> <%=image_tag("/guarrada/Debug/foto.jpg") %>
> </div>
Move your JavaScript outside of your page. This technique is designed to
be unobtrusive, then your jamming it right back into your page making
obtrusive again.
Start by putting your script code in the JavaScript file that Rails
provides you by default (public/javascripts/application.js). And make
sure you include the default script files in your <head> section:
<head>
...
<%= javascript_include_tag :defaults %>
...
</head>
This one line will include the necessary Prototype JavaScript files, and
also include public/javascripts/application.js for you.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.