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
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
You could try any of these - I’m not sure which might work:
<% unless @included_once
@included_once = true %>
<% end %>
<% unless flash[:included_once]
flash[:included_once] = true %>
<% end %>
_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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs