extjs - Sencha - Conditionally adding namesapce in requires -
i have requirement want add namespaces in requires conditionally.
e.g. in below example want add 'views.popupgrid' name space on specific condition. it's loaded.
requires: ['ext.window.messagebox','views.popupgrid','user.myuser'  ] 
conditional dependencies not supported sencha toolchain. while able write in text editor of choice
requires:[     (location.hash=='#test')?'testpopup':'normalpopup' ] and work in uncompiled version, sencha cmd not able compile correctly, , throw errors.
therefore, sencha architect not support syntax.
what can do, while staying standards-compliant: can use ext.loader.loadscript, e.g. this:
ext.define('myform',{     extend: 'ext.form.panel'     initcomponent:function() {         var me = this;         me.callparent(arguments);         if(x==3) ext.loader.loadscript({             url:'mycustomformcomponent.js',             onload:function(){                 me.add({                     xtype:'mycustomformcomponent'                 });             })         });     } }) please note in case have deliver mycustomformcomponent.js alongside minified app.js, because dependency cannot resolved toolchain. also, depending on connection, there may visible delay before resource loaded , component added form.
it faster , smoother load dependency, if intend deliver app single minified javascript file (e.g. using sencha cmd).
Comments
Post a Comment