Created
December 17, 2013 07:49
-
-
Save trabus/8001480 to your computer and use it in GitHub Desktop.
Using Isotope.js with Ember.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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') | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.