Created
January 7, 2010 03:33
-
-
Save jordanbrock/270956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// All A tags with class 'get', 'post', 'put' or 'delete' will perform an ajax call | |
jQuery('a.get').live('click', function() { | |
var link = jQuery(this); | |
//$(document).trigger('loading.facebox'); | |
$.get(link.attr('href'), function(data) { | |
if (link.attr('ajaxtarget')) | |
jQuery(link.attr('ajaxtarget')).html(data); | |
}); | |
return false; | |
}).attr("rel", "nofollow"); | |
jQuery('a.post').live('click', function() { | |
var link = jQuery(this); | |
$.post(jQuery(this).attr('href'), "_method=post", function(data) { | |
if (link.attr('ajaxtarget')) | |
jQuery(link.attr('ajaxtarget')).html(data); | |
}); | |
return false; | |
}).attr("rel", "nofollow"); | |
jQuery('a.put').live('click', function() { | |
var link = jQuery(this); | |
$.post(jQuery(this).attr('href'), "_method=put", function(data) { | |
if (link.attr('ajaxtarget')) | |
jQuery(link.attr('ajaxtarget')).html(data); | |
}); | |
return false; | |
}).attr("rel", "nofollow"); | |
jQuery('a.delete').live('click', function() { | |
var link = jQuery(this); | |
$.post(jQuery(this).attr('href'), "_method=delete", function(data) { | |
if (link.attr('ajaxtarget')) | |
jQuery(link.attr('ajaxtarget')).html(data); | |
}); | |
return false; | |
}).attr("rel", "nofollow"); | |
jQuery('a.get, a.post, a.put, a.delete').removeAttr('onclick'); | |
jQuery('form.ajax').live('submit', function() { | |
jQuery(this).ajaxSubmit(); | |
return false; | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment