diff --git a/src/dom_components/model/Component.js b/src/dom_components/model/Component.js index 2ea672312..807cc5a5d 100644 --- a/src/dom_components/model/Component.js +++ b/src/dom_components/model/Component.js @@ -184,6 +184,27 @@ module.exports = Backbone.Model.extend(Styleable).extend({ }, + /** + * Find inner models by query string + * ATTENTION: this method works only with alredy rendered component + * @param {string} query Query string + * @return {Array} Array of models + * @example + * model.find('div > .class'); + * // -> [Component, Component, ...] + */ + find(query) { + const result = []; + + this.view.$el.find(query).each((el, i, $el) => { + const model = $el.data('model'); + model && result.push(model); + }); + + return result; + }, + + /** * Once the tag is updated I have to remove the node and replace it */