How do I dynamically create a button with an image ?

I would like to implement a button with and image pulled from a url at runtime . How would I go about doing this? I don't want to hardcode the img url I want to be able to pass it to the Button kind.

Here is the code for my button below
enyo.kind({
    name : "MediaItem",
    kind : "onyx.Button",
    classes : "repeater-item class1 item",
    style : "width:150px;height:100px;margin-bottom:250px;",
    published : {
        mediaImgUrl : ""
    },
    create : function(){
        this.inherited(arguments);
        this.colorChanged();
    },
    components : [
        { tag: "img", name: "thumbnail", attributes : {src : this.mediaImgUrl } },
        { tag: "span", name: "title",  classes: "name"}
    ],
    handlers: { 
        ontap: "goToShow"
    },
    goToShow : function(inSender, inEvent){
        this.log("Sender: "+inSender.name);
    },
    colorChanged : function(oldVlaue){
      // possibly set background here
    }
});

Comments

Sign In or Register to comment.