" tags Is there a way to make drop_receiving_element not generate "// ...">

Get scriptaculous helper drop_receiving_element don't generate "<script>" tags

Is there a way to make drop_receiving_element not generate "// ..

+1


source to share


2 answers


Code drop_receiving_element

-

def drop_receiving_element(element_id, options = {})
  javascript_tag(drop_receiving_element_js(element_id, options).chop!)
end

      

javascript_tag

is what adds the script tags, so it looks like you should just leave them and type in yourself.



drop_receiving_element_js(element_id, options).chop!

      

Note. It could be a private method, in which case just use

send(:drop_receiving_element_js, element_id, options).chop!

      

+1


source


I'm not sure what you want to know (the job of the script helper is to write scripts in tags). But if you want to place the code somewhere else, like at the bottom of the page, since the javascript loading last time makes the page faster, you can use content_for

.

<% content_for :inline_javascript do %>
   <%# Script helpers here %>
<% end %>

      

then at the bottom (or wherever you want) you put this line:



<%# Include tags for other Js code the inline scripts rely on above here %>
<%= yield :inline_javascript %>

      

This does not work for asynchronous content (ajax), but on the other hand the second script includes is already loaded when the page is refreshed with ajax content.

(You can write your own helper that, depending on the type of request, either uses the content_for variable or writes an inline script tag. I've done one before, I can try to find it if you want me to)

0


source







All Articles