成为Dojo的新手我正试图用值来初始化Dijit表单,例如从存储中读取,XHR等。
但是,调用form.setFormValues()
会导致http://yandex.st/dojo/1.7.3/dojox//form/manager/_Mixin.js
TypeError: invalid 'in' operand this.formWidgets
我有什么问题或者这是一个Dojo问题吗? (完整的样本也可以在这里找到:http://pastebin.com/7LUHr3iA)
<!-- language-all: lang-html -->
`
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.3/dijit/themes/claro/claro.css" media="screen">
<script type="text/javascript">
dojoConfig = {async: true,parseOnLoad: true};
</script>
<script type="text/javascript" src="http://yandex.st/dojo/1.7.3/dojo/dojo.js"></script>
<script type="text/javascript">
require(["dijit/form/TextBox","dijit/form/Button","dojox/form/Manager",
"dojo/parser","dojo/dom","dijit/registry"], function () {});
</script>
</head>
<body class="claro">
<form id="myForm" method="post" data-dojo-type="dojox.form.Manager">
<label for="name">Name</label>
<input id="name" name="nameField" data-dojo-type="dijit.form.TextBox"/><br/>
<label for="surname">Surname</label>
<input id="surname" name="surnameField" data-dojo-type="dijit.form.TextBox"/><br/>
<button data-dojo-type="dijit.form.Button">Submit</button>
<script type="dojo/method" event="startup">
var form = dijit.byId("myForm");
form.setFormValues({
nameField: "Hello",
surnameField: "World"
});
</script>
</form>
</body>
</html>
`
答案 0 :(得分:0)
Dojo 1.7是异步的。代码应采取以下形式:
require(["dependency"], function(dep) {
// use dependency
});
当您尝试在页面下方进一步引用dojox/form/Manager
时,没有理由相信dijit.byId
。
注册表是引用窗口小部件的正确方法,而不是{{1}}格式的1.6样式代码。请参阅livedocs。
另请参阅dojo/domReady!
插件。