Skip to content

Instantly share code, notes, and snippets.

@jarsen
Created June 9, 2010 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarsen/431854 to your computer and use it in GitHub Desktop.
Save jarsen/431854 to your computer and use it in GitHub Desktop.
// JQUERY AJAX FUNCTIONALITY
// Added by Jason Larsen
// 06 May 2010
// adds .ajax and .ajax_node classes
// .ajax will load any page via ajax
// .ajax_node will load the drupal node at the specified href (loads only content)
//
// to implement, simply give the desired element the class of either ajax, or ajax_node,
// and include a href tag with the desired URL
//
// EX: <a class="ajax_node" href="/technology">AJAX Action!</a></p>
$(document).ready(function() {
// AJAX functionality for drupal nodes
$(".ajax_node").click(function() {
var ajax_src = $(this).attr("href"); // we're gonna load the href
// empty target div and load in content
// the space in the string before the #id is necessary
$("#ajax_area").empty().load(ajax_src + " #ajax_wrapper");
return false; // stops the link from following through
});
// General AJAX fucntionality
$(".ajax").click(function() {
var ajax_src = $(this).attr("href");
$("#ajax_area").empty().load(ajax_src);
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment