Browse Source

Add `replaceWith` method to Component

pull/1042/merge
Artur Arseniev 9 years ago
parent
commit
db47de6ecf
  1. 13
      src/dom_components/model/Component.js

13
src/dom_components/model/Component.js

@ -263,6 +263,19 @@ const Component = Backbone.Model.extend(Styleable).extend(
coll.add(this, { at });
},
/**
* Replace a component with another one
* @param {String|Component} el Component or HTML string
* @return {Array|Component} New added component/s
* @private
*/
replaceWith(el) {
const coll = this.collection;
const at = coll.indexOf(this);
coll.remove(this);
return coll.add(el, { at });
},
/**
* Emit changes for each updated attribute
*/

Loading…
Cancel
Save