Prefijo Sustantivo
Prefijo Sustantivo

Reputation: 525

dojo.dialog.change size after content has been set

require(["dojo","dojo/dom-attr"], function(dojo, domAttr){
    var dlg =dijit.byId("my_dialog");       
    domAttr.set(dlg, "content", "this is a text");


    //dlg.set("dimensions", [400, 200]);
    //dojo.style("my_dialog", "width", "300px");                    
    //dlg.resize({h: 500, w: 500});
});

I have a dijit.dialog. I set its text dynamically but the dialog's size is way too big. i've tried the three things commented above to no avail.

Upvotes: 1

Views: 1385

Answers (1)

GibboK
GibboK

Reputation: 73918

Just set property style with the right dimension for your dijit/dialog.

In the following example we set dimension width to 500px setting inline CSS for dialog dom element.

Live example:

https://jsfiddle.net/358rjoch/

require(["dijit/Dialog", "dojo/domReady!"], function(Dialog){
    myDialog = new Dialog({
        title: "My Dialog",
        content: "Test content.",
        style: "width: 500px"
    });
});

<button onclick="myDialog.show();">show</button>

Alternatively you can use only CSS (no inline), for example you can give an ID to your dialog widget and use a CSS selector for its style.

Live example:

https://jsfiddle.net/o15mbodm/

require(["dijit/Dialog", "dojo/domReady!"], function(Dialog){
    myDialog = new Dialog({
        id:"myDialog", // your id here
        title: "My Dialog",
        content: "Test content."
    });
});

#myDialog{
  width: 500px;
  height:400px;
}

You can find a detailed list of methods and properties for dijit/dialog widgets at the following link:

http://dojotoolkit.org/api/?qs=1.10/dijit/Dialog

Upvotes: 1

Related Questions