Do you know a good way to do this
? I mean how to instantiate a class just with it's name as string, I
use window global object, but I dont know if it's a good practice!!
is can.Construct has a trick around this?
Mohamed Cherif BOUCHELAGHEM
- can.Control.extend('MyControl',{
- init:function(el,opts){
- el.html('HOLLA');
- },
- 'click':function(el,ev){
- console.log(el);
- }
- });
- var isFunction=can.isFunction;
- can.view.attr('ui-ctrl',function(el,attrData){
- var control=el.getAttribute('ui-ctrl');
- var controlKlass=window[control];
- if(can.isFunction(controlKlass)) {
- new controlKlass(el,{});
- }
- });
-
- $('#app').html(can.view('tpl'));
Mohamed Cherif BOUCHELAGHEM