以编程方式创建“漂亮”表单

时间:2013-08-02 13:26:17

标签: javascript dojo

我的对话

var dia = new Dialog({
    content: form,
    title: 'Create a new test',
    style: "width: 300px; height: 165px;"
});

我想创建一个“漂亮”的格式化表单。

此刻我做了类似的事情:

var form = new Form();

form.domNode.appendChild(dojo.doc.createTextNode("Name:"));

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

form.domNode.appendChild(dojo.doc.createTextNode("Upload File:"));

new Uploader({ name: "File",
    label: "Select file",
    id: "addDia",
    multiple: false,
    uploadOnSelect: false,
    url: "to/the/ethreal"
}).placeAt(form.containerNode);

new FileList({
   uploader: up
}).placeAt(form.containerNode);

问题:表单将elemts任意排列。如何实现这样的目标:

"Label text:" TextBox
"Label text:" Uploader
FileList

或垂直安排:

"Label text:"
TextBox
"Label text:" 
Uploader
FileList

1 个答案:

答案 0 :(得分:0)

没有这样的CSS:

var form = new Form();

var p = dojo.create("div", {}, form.domNode); 
p.appendChild(dojo.doc.createTextNode("Name:"));
new TextBox({
  placeHolder: "Name"
}).placeAt(p);

p = dojo.create("p", {}, form.domNode);
p.appendChild(dojo.doc.createTextNode("Upload file:"));
var up = new Uploader({ name: "File",
    label: "Select file",
    id: "addDia",
    multiple: false,
    uploadOnSelect: false,
    url: "to/the/ethreal"
}).placeAt(p);

"Label text:" TextBox
"Label text:" Uploader