You could try any of these - I''m not sure which might work:
1) An instance variable in your partial
<% unless @included_once
@included_once = true %>
<script> ... javascript here </script>
<% end %>
2) The flash hash:
<% unless flash[:included_once]
flash[:included_once] = true %>
<script> ... javascript here </script>
<% end %>
3) Finally, you could make it a method in your controller:
_partial.rb:
<%= @controller.script_include %>
controller.rb:
def script_include
unless @script_included
@script_included = true
"... string holding javascript "
else
"" # empty string since already called once
end
end
Any of those may work - I would try them in the order listed. HTH!
Justin
On 3/16/06, G?bor Sebesty?n <segabor@gmail.com>
wrote:> Hi!
>
> I have to include javascript code into my partial but I should do it
> once. How can I do that?
> What is the rule of thumb?
>
> G?bor
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>