SoFunction
Updated on 2025-04-10

jQuery+.net realizes browsing more content (adapted to php version)


(function( $ ){
var target = null;
var template = null;
var lock = false;
var variables = {
'last' : 0
}
var settings = {
'amount' : '10',
'address' : '',
'format' : 'json',
'template' : '.single_item',
'trigger' : '.get_more',
'scroll' : 'false',
'offset' : '100',
'spinner_code': ''
}

var methods = {
init : function(options){
return (function(){

if(options){
$.extend(settings, options);
}
template = $(this).children().wrap('<div/>').parent();
('display','none')
$(this).append('<div class="more_loader_spinner">'+settings.spinner_code+'</div>')
$(this).children().remove()
target = $(this);
if( == 'false'){
$(this).find().bind('',methods.get_data);
$(this).more('get_data');
}
else{
if($(this).height() <= $(this).attr('scrollHeight')){
('get_data',*2);
}
$(this).bind('',methods.check_scroll);
}
})
},
check_scroll : function(){
if((()+()+parseInt()) >= ('scrollHeight') && lock == false){
('get_data');
}
},
debug : function(){
var debug_string = '';
$.each(variables, function(k,v){
debug_string += k+' : '+v+'\n';
})
alert(debug_string);
},
remove : function(){
().unbind('.more');
('.more')
().remove();
},
add_elements : function(data){
//alert('adding elements')

var root = target
// alert(('id'))
var counter = 0;
if(data){
$(data).each(function(){
counter++
var t = template
$.each(this, function(key, value){
if(('.'+key)) ('.'+key).text(value);
})
//('id', 'more_element_'+ (++))
if( == 'true'){
// (())
('.more_loader_spinner').before(())
}else{
// alert('...')

().before(())

}

(+':last').attr('id', 'more_element_'+ ((++)+1))

})


}
else ()
('.more_loader_spinner').css('display','none');
if(counter < ) ()

},
get_data : function(){
// alert('getting data')
var ile;
lock = true;
(".more_loader_spinner").css('display','block');
$().css('display','none');
if(typeof(arguments[0]) == 'number') ile=arguments[0];
else {
ile = ;
}

$.post(, {
last : ,
amount : ile
}, function(data){
$().css('display','block')
methods.add_elements(data)
lock = false;
}, )

}
};
$. = function(method){
if(methods[method])
return methods[ method ].apply( this, ( arguments, 1 ));
else if(typeof method == 'object' || !method)
return (this, arguments);
else $.error('Method ' + method +' does not exist!');

}
})(jQuery)