如何以编程方式创建 dijit 文本框?

How do I create a dijit TextBox programmatically?

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

以下答案摘自linktwo

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