当我在IE9中运行我的Web应用程序时出现以下错误。该应用程序使用 Struts 和 DOJO UI 。
开发控制台显示:
TypeError: Unable to get value of the property 'set': object is null or undefined
在FF或其他浏览器中不会发生此错误。我已经看过这个问题的其他解决方案,似乎没有解决我的问题。
我已尝试在网页的头部使用标记:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
失败的JavaScript:
require(["dojo/on", "dojo/dom", "dojo/_base/lang", "dojo/domReady!", "dojo/query","dijit/registry"],
function (on, dom, lang, query) {
$(document).ready(function () {
var addButton = dijit.byId('addName');
if(addButton){
addButton.on('click', function (evt) {
evt.preventDefault();
grid.addRecord('name');
});
}
});
答案 0 :(得分:1)
进行以下更改,你应该好好去。
// Moved dojo/domReady! at the end. Added dojo/ready module.
require(["dojo/on", "dojo/dom", "dojo/_base/lang", "dojo/ready", "dojo/query","dijit/registry", "dojo/domReady!" ],
// The callback list below should match the modules in the require statement.
function (on, dom, lang, ready, query, registry) {
// $(document) refers to Jquery plugin. Are you using Jquery
//$(document).ready(function () {
ready(function () { // using the dojo/ready module.
// changed dijit to registry
//var addButton = dijit.byId('addName');
var addButton = registry.byId('addName');
if(addButton){
addButton.on('click', function (evt) {
evt.preventDefault();
grid.addRecord('name');
});
}
});