Components - write-software/enginejs GitHub Wiki

Components

Components are the controllers in EngineJS.

#Select

A quick way to add a dropdown selectable list

    var listArray = [
            { text:"A Ford car", value:"F" },
            { text:"A BMW car", value:"B" }
         ];
    var options = new select({  
        id:"selCarType",
        data:listArray,
        optionValue:'text',
        optionText:'value',
        multiple:false,
        methods:{
            onselected:function(sSelected)
            {
                myModel.set("answers."+this._id,sSelected);
            }
        }
    });

or you can use a model object

var myModel= new model({
    cars:[
       { text:"A Ford car", value:"F" },
       { text:"A BMW car", value:"B" }
    ]
},{ name:'myModel'});

    var options = new select({  
        id:"selCarType",
        dataBind:'cars',
        optionValue:'text',
        optionText:'value',
        multiple:false,
        methods:{
            onselected:function(sSelected)
            {
                myModel.set("answers."+this._id,sSelected);
            }
        }
    },myModel);

To add this to your view just include a tag.

<selCarType></selCarType>

Where ever you need to render the component.

⚠️ **GitHub.com Fallback** ⚠️