具有此JS文件:
define(["dojo/_base/lang",
"dojo/dom",
"dojo/dom-class",
"dojo/dom-attr",
"dojo/query",
"dojo/on",
"dojo/string",
"dojo/dom-construct",
"dojo/sniff",
"dojo/ready",
"dojo/Deferred",
"dijit/registry",
"caretalks/utils/form/addressForm",
"caretalks/dialogManager",
"caretalks/utils/placeholders",
"caretalks/widget/Button",
"caretalks/widget/MenuItem",
"caretalks/widget/form/Select",
"caretalks/validation/Validator"],
function(lang, dom, domClass, attr, query, on, string, construct, sniff, ready, Deferred, registry, addressForm, dialogManager,
placeholders, Button, MenuItem, Select, Validator) {
和此功能:
handleSuccess : function(response) {
var obj = JSON.parse(response);
var node = dom.byId("phoneNumber.errors"); <<--- returns null!
},
和该函数的调用:
var node1 = dom.byId("phoneNumber.errors"); <<--- returns NOT null!
var _self = this;
this.showPropagateChangeDialog(args.propagateChangesDialog, document.forms[args.formName]).then(function(){
console.info('Posting ' + args.formName + ' to URL: ' + args.url + ' with: ', bindings);
caretalks.requestManager.ajaxPost(bindings).then(_self.handleSuccess,placeholders.enable);
});
我需要使用div
来获得dom.byId()
,当我在函数外使用它时,它将返回所需的实际值,但是当它在函数内时,它将返回null。
dom已初始化,并且可以在此处找到byId()
,但所需的值是返回undefined
。
如何解决此问题? 我在这里想念什么?