Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8823915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:28:39+00:00 2026-06-14T06:28:39+00:00

I’m using Masonry and Embedly plugin to display embedded content, I’ve put together an

  • 0

I’m using Masonry and Embedly plugin to display embedded content, I’ve put together an example here.

My jQuery is as follows

//embedly

    $('.box').find('a').embedly({
      maxWidth: 260,
      wmode: 'transparent',
      method: 'after',
      chars: 50,
      width: 260,
      key:':cd54253e69944ae18ad5ece38b4d0e1e' //temporal
    });


//masonry

   var $container =  $('#main-container');

    $container.imagesLoaded( function(){
        $container.masonry({
          itemSelector: '.box',
          isAnimated: true,
          isFitWidth: true
      });
    });

It appears the Masonry plugin loads first and it causes the overlapping problem (they only show correctly when you resize the result window) I’ve read that I could use callback functions or retrigger Masonry once embedly has finished rendering content, but I don’t know how to do it. Can you help me? Is there any other solution to fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:28:40+00:00Added an answer on June 14, 2026 at 6:28 am

    You have an asynchronous timing problem. The masonry layout code is firing before the content has had a chance to load.

    So what you want to do is wait to call masonry until after all your content is loaded. You might be tempted to use a timeout, which will tend to cause race conditions.

    Ideally, embedly would have a better API and return some kind of deferred promise object the way ajax calls do. Unfortunately, it seems like there isn’t anything that clean so we have to do a few hand stands.

    If you define a success: callback, then apparently you have to insert the content yourself.

    Fortunately, embedly() fires it’s own event after the content is loaded and displayed which you can bind a callback to.

    There are probably many more elegant ways of accomplishing this but for purposes of a simple example using an ugly global, we keep track of the number of loaded content pieces. Each time the embedly event fires indicated a piece of content has been loaded, we increment the counter. Once we reach the total number of matched elements, we know all content has been loaded and we call masonry.

    While it’s not pretty, it works: http://jsfiddle.net/sJ5vc/

        //embedly
    var matches = $('.box').find('a').length;
    var loaded = 0;
    
    // we call this from the embedly callback after all 
    // content has been loaded.
    function callMasonry() {
        var $container = $('#main-container');
    
        $container.imagesLoaded(function() {
            $container.masonry({
                itemSelector: '.box',
                isAnimated: true,
                isFitWidth: true
            });
        });
    }
    
    
    var result = $('.box').find('a').embedly({
        maxWidth: 260,
        wmode: 'transparent',
        method: 'after',
        chars: 50,
        width: 260,
        key: ':cd54253e69944ae18ad5ece38b4d0e1e' //temporal
    }).bind('embedly-oembed', function(e, oembed) {
    
        // not as elegant as I would like but increment
        // the counter. Once we have gotten to 
        // the number of matches call masonry
        //
        // It would be much cleaner if embedly could return some kind
        // of deferred object that gets resolved after all matched
        // content has been loaded. 
    
        loaded++;
    
        console.log("loaded " + oembed.title);
    
        if (loaded == matches) {
            callMasonry();
        }
    
    
    });;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I am reading a book about Javascript and jQuery and using one of the
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.