如何以编程方式创建dijit TextBox?

时间:2015-11-28 11:17:04

标签: dojo dijit.form

所以,我有一个DialogBox,我要求输入一个新文本。基本上它是一个重命名元素的对话框,我需要名称的新值。但我无法弄清楚如何以编程方式创建文本框。以声明方式做的不是一种选择。

1 个答案:

答案 0 :(得分:2)

以下答案取自链接two

require([
    "dijit/Dialog", 
    "dijit/form/Form", 
    "dijit/form/TextBox", 
    "dijit/form/Button", 
    "dojo/domReady!" 
], function(Dialog, Form, TextBox, Button) 
{
    var form = new Form();

    new TextBox({
        placeHolder: "Name"
    }).placeAt(form.containerNode);

    new Button({
      label: "OK"
    }).placeAt(form.containerNode);

    var dia = new Dialog({
        content: form,
        title: "Dialog with form",
        style: "width: 300px; height: 300px;"
    });
    form.startup();
    dia.show();
});//~require