Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dojo Dijit Dialog relative position. is it possible?

I want to position Dojo's Dijit Dialog relative to one of my html element. is it Possible? If yes. How?

currently it always shows dialog in middle of viewport.

Can any one help me regarding the matter?

Thanks.

amar4kintu

like image 326
amar4kintu Avatar asked Feb 28 '23 09:02

amar4kintu


2 Answers

Another way that I do this (not great because I override a private method but it gives me the flexibility I want):

var d = new Dialog({
    title:"Your Dialog",
    _position:function(){
        if(this.refNode){
            p = Geo.position(this.refNode);
            Style.set(this.domNode,{left:p.x + "px", top:p.y + "px"});
        }
    },

    showAround:function(node){
        this.refNode = node;
        this.show();
    }
});
d.showAround(dojo.byId("someNode"));

This example uses "dojo/dom-style" as Style and "dojo/dom-geometry" as Geo.

like image 166
ace Avatar answered Mar 08 '23 06:03

ace


I did that by adjusting default absolute position of dijit.dialog using dojo..

I used following code to readjust absolute position of dialog to what I want..

dijit.byId('dialog').show();

dojo.style('dialog','background-color','#AAAAAA');

var co = dojo.coords('period'); // element below which I want to display dialog

dojo.style('md1','top',(co.y + 25)+'px');
dojo.style('md1','left', co.x+'px');

Hopefully this will help someone..

Thanks.

amar4kintu

like image 27
amar4kintu Avatar answered Mar 08 '23 08:03

amar4kintu