PDA

View Full Version : Extjs 4.2 minification



10 Jan 2017, 1:22 AM
I have a piece of code in Extjs 4.2




Ext.define('Cms.controller.MainController', {
extend : 'Ext.app.Controller',
stores : [],
init:function(application){
var me = this;
Ext.topic.subscribe("collaborationRender", function(object){
var data = {
userName:userName,
productCode:productCode,
objectFilter:objectFilter,
description:description,
};
Ext.Ajax.request({
url : '',
method : 'POST',
jsonData : data,
headers: { 'Content-Type' : 'application/json' },
success : function(response, opts) {
me.getController('Cms.controller.WallController');
me.getController('Cms.controller.PostController');
me.getController('Cms.controller.UserOptionsCT');
var view = Ext.getCmp(object[0].data.componentId);
view.removeAll();
view.insert({
items: [{
xtype: 'WallContainer'
}
]
});
},
failure : function(response) {
}
});
});
} });




when i minify this code and run it.. i get error as "the specified callback is not defined".
It works perfectly before minification.


Can somebody guide me ? i dnt seem to understand what might be the issue.
Thanks in Advance

vick_44
12 Jan 2017, 11:16 PM
What i am about to say is primarily a guess,
Since the error complains specifically about call back function, you can debug this with trial n error process. Apparently there are only two callback functions in this controller, remove both of em and run the application. If it still throws an error then we know problem do not pertain to those two. If it does not complain, you can introduce "success" callback function. If it doesnt throw an error you would know that problem is with other one. If it does throw an error probably you might have to improvise your success callback function.

Speaking about success call back function, i dont understand the purpose of below lines


me.getController('Cms.controller.WallController');
me.getController('Cms.controller.PostController');
me.getController('Cms.controller.UserOptionsCT');

If the purpose of the above is to load controllers at run time, probably you can move the loading part when the MainController loads with requires: [ ] and controllers: [ ] option.

I know none of the above is a definitive solution, but you can give it a shot though.