PDA

View Full Version : Best approach for general functions in an ExtJS MVC



xisc0
13 Dec 2012, 11:57 AM
I'm following to build my applications the ExtJS MVC model...

I have this structure in the main folder. I made a function to show messages to the user whether if an error happen or the user need some information. Do you think this is a good approach? or there is something better that I can do following the ExtJS MVC model to reuse my function?

Proyect

-Erros


- errors.js

- Applications

App1

*store
* model
*controller
*view

App2

*store
* model
*controller
*view



function ShowMsg (StrTitle, StrError, StrIcon) {

var ExtJsIcon;

if (StrIcon == 'INFO') {
ExtJsIcon = Ext.Msg.INFO;
}
else if (StrIcon == 'WARNING') {
ExtJsIcon = Ext.Msg.WARNING;
}
else if (StrIcon == 'QUESTION') {
ExtJsIcon = Ext.Msg.QUESTION;
}
else if (StrIcon == 'ERROR') {
ExtJsIcon = Ext.Msg.ERROR;
}

Ext.Msg.show({
title : StrTitle,
msg : StrError,
icon : ExtJsIcon
});

}

mitchellsimoens
15 Dec 2012, 7:51 AM
Seems fine for what I've seen.

xisc0
17 Dec 2012, 3:02 AM
Thanks master! :)