class Object

Public Instance Methods

javascript_include_tag_with_jquery(*source) click to toggle source
# File lib/jrails/asset_tag_ext.rb, line 39
def javascript_include_tag_with_jquery(*source)
  if source.first == :jrails
    javascripts = []
    if JRails.google?
      javascripts \
        << javascript_include_tag_without_jquery(JRails.jquery_path) \
        << javascript_include_tag_without_jquery(JRails.jqueryui_path) \
        << javascript_include_tag_without_jquery(JRails.jqueryui_i18n_path) \
    end
    javascripts << javascript_include_tag_without_jquery(*source)
    javascripts << yield_authenticity_javascript if protect_against_forgery?
    javascripts.join("\n")
  else
    javascript_include_tag_without_jquery(*source)
  end
end
render_with_update(options = {}) click to toggle source
# File lib/jrails/rendering.rb, line 4
def render_with_update options = {}, locals = {}, &block
  if options == :update
    update_page(&block)
  else
    render_without_update options, locals, &block
  end
end
yield_authenticity_javascript() click to toggle source
# File lib/jrails/asset_tag_ext.rb, line 18
  def yield_authenticity_javascript
<<JAVASCRIPT
<script type='text/javascript'>
 //<![CDATA[
   window._auth_token = '#{form_authenticity_token}';
  $(document).ajaxSend(function(event, xhr, s) {
    if (typeof(window._auth_token) == "undefined") return;
    if (s.data && s.data.match(new RegExp("\\bauthenticity_token="))) return;
    if (s.data)
      s.data += "&";
    else {
      s.data = "";
      xhr.setRequestHeader("Content-Type", s.contentType);
    }
    s.data += "authenticity_token=" + encodeURIComponent(window._auth_token);
  });
 //]]>
</script>
JAVASCRIPT
  end