Browse Source

Add `closest` method in Component

pull/803/head
Artur Arseniev 8 years ago
parent
commit
e625b6dc61
  1. 13
      src/dom_components/model/Component.js

13
src/dom_components/model/Component.js

@ -234,6 +234,19 @@ const Component = Backbone.Model.extend(Styleable).extend(
return result;
},
/**
* Find closest model by query string
* ATTENTION: this method works only with alredy rendered component
* @param {string} query Query string
* @return {Component}
* @example
* model.closest('div');
*/
closest(query) {
const result = this.view.$el.closest(query);
return result.length && result.data('model');
},
/**
* Once the tag is updated I have to remove the node and replace it
*/

Loading…
Cancel
Save