我想把它放在我放置data-dojo-type =" js / widget / SAUploadForm"对于上传小部件,它将在那里生成一个表单。由于页面上没有生成任何表单,因此不确定我现在的错误。
<html>
<head>
<title>Upload</title>
<script>
dojoConfig = {
async : true,
parseOnLoad : false
}
</script>
<script src="js/dojo/dojo.js"></script>
</head>
<body>
<div>
<h1 align="center">Upload</h1>
<br />
<div data-dojo-type="js/widget/SAUploadForm"></div>
</div>
</body>
</html>
我的小部件文件:SAUploadForm.js
define(["dojo/_base/declare", "dojo/dom-construct", "dojo/parser", "dijit/_WidgetBase", "dijit/_TemplatedMixin"],
function(declare, domConstruct, parser, ready, _WidgetBase, _TemplatedMixin) {
decalre("SAUploadForm", [_WidgetBase, _TemplatedMixin], {
formString: '<form method="post" enctype="multipart/form-data" action="/webapp/upload">' +
'<table>' +
'<tr>' +
'<td>File:</td>' +
'<td><input type="file" name="file" value="Browse" accept=".sub" /></td>' +
'</tr><tr>' +
'<td colspan="2"><button type="submit">Upload</button></td>' +
'</tr>' +
'</table></form>',
buildRendering: function() {
this.domNode.innerHTML = formString;
}
});
ready(function() {
parser.parse();
});
});
这位于js / widget /
答案 0 :(得分:0)
那么, 这里有太多错误的东西......
decalre
而不是declare
templateString
而非自定义formString
js/widget/SAUploadForm
ready
但您不需要declare
的结果这样的事情应该有效:
(注意:片段无法工作,因为代码需要将窗口小部件放入单独的文件中)
//This goes into js/widget/SAUploadForm.js
define(["dojo/_base/declare", "dojo/dom-construct", "dijit/_WidgetBase", "dijit/_TemplatedMixin"],
function(declare, domConstruct, _WidgetBase, _TemplatedMixin) {
return declare("js/widget/SAUploadForm", [_WidgetBase, _TemplatedMixin], {
templateString: '<form method="post" enctype="multipart/form-data" action="/webapp/upload">' +
'<table>' +
'<tr>' +
'<td>File:</td>' +
'<td><input type="file" name="file" value="Browse" accept=".sub" /></td>' +
'</tr><tr>' +
'<td colspan="2"><button type="submit">Upload</button></td>' +
'</tr>' +
'</table></form>'
});
});
//this goes into the index.html file
require(["dojo/parser", "dojo/domReady!", "js/widget/SAUploadForm"], function(parser) {
parser.parse();
});
&#13;
<script>
dojoConfig = {
async : true,
parseOnLoad : false
}
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.10.4/dojo/dojo.js"></script>
<div>
<div data-dojo-type="js/widget/SAUploadForm"></div>
</div>
&#13;