PDA

View Full Version : calling windows/dialogs made in an external JS file?



foxofinfinety
31 Aug 2010, 11:23 AM
I'm stating to be able to use Ext, but I want to put the code in a seperate file.
but, I don't know how to call the things I made in the external file.

I made this warning with shows up as soon as one gets on the page:

Ext.MessageBox.show({
title: 'Message from Adminestrator',
msg: 'please note this is a beta version of {site}.<br> not all features are working.<br> we are doing our best to make the site fully functional as soon as we can.',
buttons: Ext.MessageBox.OK,
animEl: 'page_body',
icon: Ext.MessageBox.WARNING
});and this works, but only when it's indeed inline in the main file, like this.

the problem is, how do I get this in a external JS file, in such A way it works, and I can call it, I tried this:


var betaMessage = new Ext.MessageBox({
title: 'Message from Adminestrator',
msg: 'please note this is a beta version of {site}.<br> not all features are working.<br> we are doing our best to make the site fully functional as soon as we can.',
buttons: Ext.MessageBox.OK,
animEl: 'page_body',
icon: Ext.MessageBox.WARNING
});
and then tried calling it like this:

betaMessage.show();which does nothing.
I know it's wrong (else it would have worked) but I have not the slightest idea of what it should be.:((

(in the code {site} is the name of the site, but it's not relevant so, not to spam the forums, I replaced it with a place holder for here)

foxofinfinety
7 Sep 2010, 12:28 PM
never mind, found the problem.

I tried making a variable with an object of type Ext.MessageBox, I should have just used the normal Ext.MessageBox.show() function and put that within a function, a.k.a. this:


function show_beta_warn(){
Ext.MessageBox.show({
title: 'Message from Adminestrator',
msg: 'please note this is a beta version of <site>.<br> not all features are working.<br> we are doing our best to make the site fully functional as soon as we can.',
buttons: Ext.MessageBox.OK,
animEl: 'page_body',
icon: Ext.MessageBox.WARNING
});
};and then call that function like I would if it was in the main file....