createComponent() before another component?

edited September 2013 in Newbie Questions
Hi Folks,

I have a control that renders to something like:
<section>
  <header>
    <h1>content</h1>
  </header>
</section>
I want to add a new node before the "h1" node. If I use something like this.$.header.createComponent(), the new component is added after the h1. Anyone has an idea to add it before a given node?

Cheers
andre

Comments

  • 1) use pre/code tags around code to show it correctly. The "C" button in the post editor can automatically wrap text that you select.

    2) For this, you could use the addBefore property of enyo.Component. You set it to the component you want to immediately follow the one you're adding.
    this.$.header.createComponent({content: "new stuff", owner: this}, {addBefore: this.$.h1});
    
  • oh perfect! thanks so much Ben!!! :D
Sign In or Register to comment.