desandro/isotope — Issue #111: Issue whilst dynamically adding items using 'insert' method
Author: dougajmcdonald
Created: 2011-11-12 10:03:21+00:00
State: open

Hi David,

I appreciate you're hugely busy, so not expecting a speedy response on this issue. It has however, been bugging me for a few days now and I can't quite figure out if this is a bug, or if I'm doing something wrong conceptually.

The describe the issue, I have an unordered list (initially empty), which I'm populating with list items from a jQuery based ajax request. As I understand the docs, I should be using the following syntax:

$("#imageGallery").isotope( 'insert', result );

Where my ul has an id of 'imageGallery' and result is a string of html containing my li's.

Assuming the above is the correct method, I get the following error thrown from firebug 'TypeError: $elems.filter is not a function' .

I've traced this through the debug version of isotope and the error is thrown from this linein the '_getAtoms' function:

"$atoms = selector ? $elems.filter( selector ).add( $elems.find( selector ) ) : $elems"

If I try to run the section which sets variables (which the above line is part of) I get the caller with the same error thrown from line 715 which is the following command 'var $newAtoms = this._getAtoms( $content );'

I'm not 100% sure whether I'm calling the isotope method in the wrong location, or whether this is a genuine bug.
It feels simply like the elements needed to filter upon aren't available at the point the method is called, which could well be the order the code is executed.

At the moment I'm executing the 'insert' method inside a callback of the jQuery ajax 'success' method, is this the correct placement of the code?
The docs are superb as describing in isolation what is needed, but it would be fantastic to see some more complex examples.

Thanks in advance,

Doug