Issue
Hello i´m new to web development. I´m struggling with a JS function using Yii 1.1: isotope-jquery. Trying to show a masonry image gallery with infinite scrolling. If i leave it as it is it works, but when using images they get all overlapped at the end. i should use imagesLoaded, but applying it´s being a pain...
Original code:
$defaultCallback="
function( newElements ) {
/* hide new items while they are loading*/
var newElems = jQuery( newElements );
\$isoContainer.isotope( 'appended', newElems, true );
{$this->infiniteCallback}
}";
Modified:
function( newElements ) {
/* hide new items while they are loading*/
var newElems = jQuery( newElements );
\$newElems.imagesLoaded(function(){
\$isoContainer.masonry( 'insert', newElems);
});
{$this->infiniteCallback}
}"
Error on browser console:
["math:", 222, 2853] jquery.infinitescroll.js:171
["math:", 0, 2853] jquery.infinitescroll.js:171
["heading into ajax", Array[2]] jquery.infinitescroll.js:171
["Using HTML via .load() method"] jquery.infinitescroll.js:171
["contentSelector", div.items.isotope] jquery.infinitescroll.js:171
Uncaught ReferenceError: $newElems is not defined index.php?r=products:112(anonymous function) index.php?r=products:112opts.callback jquery.infinitescroll.js:159infscr_loadcallback jquery.infinitescroll.js:327infscr_ajax_callback jquery.infinitescroll.js:501jQuery.extend.each jquery.js:595jQuery.fn.jQuery.each jquery.js:241jQuery.ajax.complete jquery.js:7465fire jquery.js:974self.fireWith jquery.js:1084done jquery.js:7818callback
i´ve tried several things, defining the var inside, passing parameters, but i cannot make it work...
probably it´s a newbie issue...
thanks for your help
Solution
So this is the solution, and works like a charm!
function( newElements ) {
/* hide new items while they are loading*/
var newElems = jQuery( newElements );
\$isoContainer.imagesLoaded(function(){
\$isoContainer.isotope( 'appended', newElems,true);
});
thanks @Macsupport
Answered By - user4055746
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.