Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
AJAX content replace
(function($) {
// scan our ajax response for replaceable content blocks then update the HTML
var updateContent = function(content) {
var $contentKeyElements = $(content).filter('[data-content-key]');
$contentKeyElements.each(function() {
var node = $(this);
var key = node.attr('data-content-key');
$('[data-content-key=' + key + ']').replaceWith(node);
$(function() {
$(document).bind('ajax:success', function(e, content) {
$.each(content, function(key, value) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.