Created
June 27, 2012 22:35
-
-
Save Shadowfiend/3007331 to your computer and use it in GitHub Desktop.
Code to rehydrate Lift comets.
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
liftComet.lift_sessionLost = function() { | |
$('body').append( | |
$('<iframe src="' + location.toString() + '">') | |
.attr('id', 'reload-iframe') | |
) | |
var newWindow = $('#reload-iframe')[0].contentWindow | |
function preventInitialCometTransaction() { | |
if (newWindow.liftComet && typeof newWindow.liftComet.lift_cometEntry == 'function') { | |
liftComet.lift_cometEntry = newWindow.liftComet.lift_cometEntry; | |
newWindow.liftComet.lift_cometEntry = function() {} | |
} else { | |
os.nextTick(preventInitialCometTransaction) | |
} | |
} | |
$('#reload-iframe').load(function() { | |
var new_toWatch = newWindow.lift_toWatch; | |
newWindow.lift_toWatch = {}; | |
var $newComets = newWindow.$('[data-lift-comet]') | |
$('[data-lift-comet]').each(function(i) { | |
this.outerHTML = $newComets[i].outerHTML; | |
}) | |
lift_toWatch = new_toWatch; | |
liftComet.lift_handlerSuccessFunc(); | |
}) | |
$('#reload-iframe').remove(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment