问题
This is an extention to stackflow qustion. I want to create div programmatically and attach the opentok subscriber cam to it and all the subscriber cam need to come under parent div "#subscription". Please let me know what I'm doing wrong in my code.
Jsfiddle
http://jsfiddle.net/6z9n65ty/55/
Updated Jsfiddle
http://jsfiddle.net/6z9n65ty/59/
Code for subscription div
    enyo.kind({
    name : "blanc.SubscriberWrapper",
    showing: true,
    stream: null,
    session: null,
    create: function(){
        this.inherited(arguments);
        if(this.stream != null && this.session != null){
            this.subscribe();
        }
    },
    subscribe: function(){
        this.session.subscribe(this.stream, this.hasNode());
    }
});
Update
I want to attach the stream to subscribeButton, the below code will add the first subscriber stream to "#subscribeButton". If second subscribe stream exist, then it will overwrite previous subscribe cam video with second stream. I want to have all the subscribers to be viewed in the screen. So I was trying to create new div using create function.
  streamCreated: function (event) {
      this.session.subscribe(event.stream, subscribeButton);
     // Add subscriber stream to a new div 
     //   this.createComponent({kind: "blanc.SubscriberWrapper", name : event.stream.id, stream: event.stream, session: this.session});
//  this.render();
  },
JSFIDDLE
http://jsfiddle.net/6z9n65ty/62/
回答1:
I believe the problem with your code is that hasNode() will return false (or is it null?) because the node isn't rendered yet.  Change create: to rendered: and it may work.
The token in your fiddle had expired so I wasn't able to test it further but couldn't. Your code that creates the new component looks correct at first blush.
You didn't say what -did- happen when the code is executed. If you're just getting blank divs, then my assumption is correct.
来源:https://stackoverflow.com/questions/28446330/how-to-add-programatically-add-new-div-using-enyojs-and-attach-to-the-subscriber