I agree that was a very poorly worded question and am well aware of its
IE specific nature.

 

I don't believe I can register a callback in this instance as I need to
close the pop up and return a value when a user clicks on a hyperlink
within the popup itself. Aren't callbacks limited to window events such
as clicking the close button, or resizing the window?

 

In any case, I decided to call an update method (present in the main
page) from the pop up passing in the return value object which does the
job ok.

 

Just out of interest Abel, you say you don't like to force users to use
modal popups, which is a feature of PWC. Why is that? I ask because I'm
using modal popups to either force the user to select a Contact, or
close the window and return to the main window which doesn't seem to be
limiting or frustrating the user.

 

Regards

 

Matt

 

 

Hi Matt,

 

These are very basic questions you are asking. Before trying to tackle 

anything with Prototype Windows, it is best to read a tutorial on 

JavaScript, and not VBScript, as that is what you seem to be using. 

showModalDialog was introduced in IE4 and has never been adopted by 

other browsers. It is considered a very bad habit to show a new window 

and preventing the user to access his main window. Unfortunately, the 

notorious window.alert() and window.prompt() still exist, but since a 

short while, Opera provides a way out of them and I hope other browsers 

will follow soon.

 

Because you don't want a user to do and act precisely when you want it 

and how you want (and even if you do, which I hope you don't, the user 

will feel differently about it), the Javascript model introduced 

asynchronous callbacks, also called: event mechanism. The basic is 

simple: when something happens (i.e., a user clicks a button, an 

XMLHttpRequest object finishes, or your own asynchronous function 

finishes) a method is called. Familiar are (I hope) methods like onload,


onclick, onbeforeupdate (IE only) etc.

 

Like all good objects that support asynchronicity, Prototype.js and 

Prototype Windows (and just about any other serious JavaScript object 

library) support asynchronous callbacks when they need to. For instance,


when a user resizes the window (when he starts, when he ends), when the 

user clicks the close button etc.

 

You'll have to get used to an event model of programming. "execution 

stops here" does not exist and is only used while debugging by using 

these notorious window.alerts (or a debugger, for that matter). So, to 

get what you want (a return value), use the Prototype Windows Classes, 

register your callback method with them (simply, just pass in the name 

of your method, see the documentation, it is all there) and place the 

code you would otherwise place after "execution stops here" in your 

callback method (or event handler, whatever name you choose for it). I 

believe the syntax in PWC was something like: onOk: myOkMethod.

 

The internet is filled with tutorials on the subject of JavaScript event


model programming, both in depth and beginners. Have a shot at it and 

then try again to tackle PWC (or any JavaScript, for that matter). You 

will find that a whole new world opens up for you.

 

Good luck coding!

 

Cheers,

-- Abel Braaksma

 

 

 

_______________________________________________
Javawin mailing list
[email protected]
http://mail.xilinus.com/mailman/listinfo/javawin_xilinus.com

Reply via email to