Ajax Contents Solution...

392 views
Skip to first unread message

ElToba

unread,
May 8, 2012, 11:25:19 AM5/8/12
to selectivizr
Is not efficient, JSLint /*evil:true*/
Saves the selectivizr code in a string and reexecute at will calling
selectivzrRedraw.

var selectivzrRedraw = (function(){
var timer, selectivizrCode;
/*
// More inefficient
if((/MSIE/).test(window.navigator.userAgent)){
timer = setInterval(reSelectivizr, 10000);
}*/

function reSelectivizr(){
if(selectivizrCode === undefined){
$.get('js/selectivizr-min.js', {}, function(data){
selectivizrCode = data;
eval(selectivizrCode);
},'text');
}else{
eval(selectivizrCode);
}
}

return reSelectivizr;
}());
selectivzrRedraw(); // FirstCall


/** AutoRedraw in jQuery .load | NO TESTED, it's a posible solution
**/

(function($){

var PREV_LOAD = jQuery.fn.load;
jQuery.fn.load = function(){

if(jQuery.isFunction(arguments[2])){
var prevCbk = arguments[2];
arguments[2] = function(){
try{
prevCbk();
}catch(e){};
selectivzrRedraw();
}
}else{
if(undefined === arguments[1]){
arguments[1] = {};
}
arguments[2] = selectivzrRedraw
}

return PREV_LOAD.apply(this, arguments);
}

}(jQuery));
Reply all
Reply to author
Forward
0 new messages