iatek / jquery-socialist

jquery social media plugin that aggregates and combines Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest and.. Combine social feeds from multiple social networks or RSS in elegant layouts via this social plugin.
http://plugins.in1.com/socialist
MIT License
629 stars 213 forks source link

callbacks #54

Closed link82 closed 11 years ago

link82 commented 11 years ago

Hello, I'm trying to use your script in combination with mCustomScrollbar but I'm stuck because I need to load it after the DOM elements has been added for my stream.

I tried to add a callback function to your script but I'm not sure where I should put the method call, even if I call it after completing the processes queue the other script doesn't find any element inside my div so it doesn't work. It works only if I try using a setTimeout to make it wait for a couple of seconds.

Here is where I'm trying to call my callback method

                $.when.apply($, processList).always(function(){

                    for (var i = 0; i < queue.length; i++) {
                       queue[i].children().appendTo($element);
                    }

                    // load isotope?
                    if (settings.isotope) {
                        $element.imagesLoaded(function(){
                            //console.log("loading iso");
                            $element.isotope ({
                                 animationEngine: 'jquery'
                            });

                            $element.removeClass('socialist-loader');

                            if (settings.random){
                                $element.isotope( 'shuffle', function(){} );
                            }
                        });
                    }
                    else {
                        $element.removeClass('socialist-loader');

                        // MY CALLBACK METHOD
                            if(settings.onSuccess){
                                settings.onSuccess();
                                console.log('stream loaded!!!');
                            }

                    }

                },function(){
                    //console.log('some requests failed.');
                });
link82 commented 11 years ago

solved by waiting the onSuccess callback from the script

$('#facebook-stream').socialist({
      networks: [
        {name:'facebook',id:'supermegapage'}
      ],
      isotope:false,
      random:false,
      fields:['source','heading','text','date'],
      maxResults:10,
      headingLength:150,
      onSuccess:function(){
        //customize scrollbars
        $('#facebook-stream').mCustomScrollbar();
      },
      onFailure:function(){
        console.log('unable to retrieve social data');
      }
    });