Extending the Dojo Dialog
March 9, 2007 12:01 pm
Occasionally certain usability suggestions seem to make sense until you actually see them in person. For one app that we recently worked on we relied heavily on the Dojo toolkit and the dialog widget which creates a modal, centered dialog layer. One suggestion we received was to not have the dialog centered, but to have it appear at the current position of the cursor. As a result, I created the MoveableDialog widget which extends the normal Dojo dialog. Although we didn't end up using this technique, it may be helpful in other instances and it also provides a good starting point for trying to extend the Dojo dialog widget.
You can grab the MoveableDialog.js and place it in your dojo/src/widgets directory then you can call it similarly to the normal Dialog (of course you would specify MoveableDialog in your dojo.require statement and in the div where you specify the dojoType). The main difference is the show function now accepts two parameters for the coordinates of the left and top position of where to place the dialog. If you combine it with this mousetracking script you can have the dialog appear at the cursor position.

