Skip to content

Instantly share code, notes, and snippets.

@baldwindavid
Created April 1, 2009 17:24
Show Gist options
  • Save baldwindavid/88795 to your computer and use it in GitHub Desktop.
Save baldwindavid/88795 to your computer and use it in GitHub Desktop.
Jquery / Rails Basic Setup
// outside of this you can refer to jQuery as $j
$j = jQuery.noConflict();
jQuery(document).ready(function($){
// your stuff goes here!
// just use $ to refer to jQuery from within here
});
jQuery.ajaxSetup({
'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
});
jQuery(document).ajaxSend(function(event, request, settings) {
if (typeof(AUTH_TOKEN) == "undefined") return;
settings.data = settings.data || "";
settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment