Last active
January 12, 2016 14:45
-
-
Save RickButler/0924c7a96617187995e6 to your computer and use it in GitHub Desktop.
A helper method for an ampersand-view / ampersand-model to fetch the children if they have a url and fetch method.
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
var View = require('ampersand-view'); // you can use ampersand-model/ampersand-state here too | |
var _ = require('lodash'); | |
module.exports = View.extend({ | |
fetchChildren: function(options) { | |
_.chain(this._children) | |
.keys() | |
.each(function(key) { | |
if(_.isFunction(this[key].url) && _.isFunction(this[key].fetch) { | |
this[key].fetch(options); | |
} | |
}, this); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment