Skip to content

Instantly share code, notes, and snippets.

@trabus
Created December 17, 2013 07:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trabus/8001480 to your computer and use it in GitHub Desktop.
Save trabus/8001480 to your computer and use it in GitHub Desktop.
Using Isotope.js with Ember.js
// Controller
App.SomeController = Ember.ArrayController.extend({
items: []
});
// View
App.SomeView = Ember.View.extend({
// this will be run once the didInsertElement event occurs, and any time an item is added
initIsotope: function(){
// use the run loop to execute after rendering is complete
Ember.run.scheduleOnce('afterRender', this, function(){
var iso = this.$('#isotope-container");
// setup container
iso.isotope({
//options
itemSelector : '.item',
layoutMode : 'fitRows'
});
// find and add any items that aren't already initiated
iso.isotope('appended', iso.find('.item:not(.isotope-item)'));
});
}.on('didInsertElement').observes('controller.items.@each'),
// this will clean up your container
cleanUpIsotope: function(){
// returns elements to original state to prevent memory leaks
this.$('#isotope-container").isotope('destroy');
}.on('willClearRender')
});
@krivaten
Copy link

Thanks for this. You do have one small typo on line 10 and 27. Just need to replace the double quotes have '#isotope-container" with single.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment