createComponent() before another component?

edited September 2013 in Newbie Questions
Hi Folks,

I have a control that renders to something like:



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?



  • 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.