Login Register

Simple TooltipDialog opened by click on a div

Hi all,

I am switching to dojo 1.0.2 (and dijit) from 0.9 and do have some issues with a hack I did in 0.9.

The goal is to have a Tooltipdialog appear below a square div (that contains a chosen color as bacground color). Because I have multiple of those div's that need to show the same Tooltip dialog, I just want to have one TooltipDialog and programmatically open and close it. The dialog itself just contains a colorpalette and upon choosing a color i will close the dialog myself.

So here is what I got so far:

<div dojoType="dijit.TooltipDialog" id="colorDialog" title="First Dialog" style="display:none;">
                    <div dojoType="dijit.ColorPalette" id="colorPalette"></div>
                        <a id="linkTransparent" href="#">use transparent background</a>
      </div>

I had to set display:none as show="false" did not work. The dialog was then still displayed.

Now:

How can I programmatically open that dialog at the current mouse position (or relative to the div the user clicked on) and how can I close it? I tried onOpen() which does not work for me...

Thanx! Any ideas are welcome. I hope this is the right way to achieve this at all... any suggestions are also more than welcome.

solved.... and it was very easy once one knows :-)

Answering myself.

One should be able to 'popup' any widget, including the TooltipDialog with all content with the popup.open() method:

dijit.popup.open({popup: dijit.byId("colorDialog"), x: e.pageX, y: e.pageY});

colorDialog is the TooltipDialog from above. One can then simply connect the colorChooser to another function that will call the close method:

dijit.popup.close(dijit.byId("colorDialog"));