好的是删除了无关逻辑的dijit定义:
define([
'dojo/_base/declare', 'dojo/on',
'dojo/dom-class', 'dojo/dom-attr', 'dojo/dom-style',
'libs/bower_components/lodash/collection/where', 'libs/bower_components/lodash/collection/pluck',
'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dijit/_WidgetsInTemplateMixin',
// templates & widget css
'dojo/text!./templates/FilterableCheckedMultiSelectDD.html', 'xstyle/css!./css/FilterableCheckedMultiSelectDD.css',
//Not Referenced
'dijit/TooltipDialog', '../FilterableCheckedMultiSelect/FilterableCheckedMultiSelect'
], function (
declare, on,
domClass, domAttr, domStyle,
where, pluck,
_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin,
template, css
) {
return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
widgetsInTemplate: true,
templateString: template,
title: 'Dropdown',
_setTitleAttr: function(newTitle){
this._set("title", newTitle);
this.btn.set('label', newTitle);
}
})
});
现在,以下工作在chrome中运行良好:
<select data-dojo-type="libs/dijits/FilterableCheckedMultiSelectDD/FilterableCheckedMultiSelectDD"
id="section" data-dojo-attach-point="section" data-dojo-props="title:'Sections'"></select>
但它在IE9中不起作用。它会引发以下错误:
dojo/parser::parse() errorTypeError: Unable to get value of the property 'set': object is null or undefined
然后我尝试在javascript中声明它:
this.section = new FilterableCheckedMultiSelectDD({
title: 'Sections'
});
domConstruct.place(this.section, 'sectionContainer');
但是它引发了同样的错误(尽管不是通过解析器):
TypeError: Unable to get value of the property 'set': object is null or undefined
我也尝试了这个:
this.section = new FilterableCheckedMultiSelectDD();
this.section.set('title', 'Sections');
domConstruct.place(this.section, 'sectionContainer');
同样的错误。
我看到了这个帖子: IE Error TypeError: Unable to get value of the property 'set': object is null or undefined
虽然错误似乎非常相似,但原因(和解决方案)似乎有很大不同。
以下是模板:
<div>
<button class="filterable-checkbox-dd" data-dojo-attach-point="btn" data-dojo-type="dijit/form/DropDownButton">
<span data-dojo-attach-point="label"></span>
<div data-dojo-attach-point="contentContainer" data-dojo-type="dijit/TooltipDialog">
<div style="width: 100%; max-height: 250px; background: #fff; overflow: auto;" data-dojo-type="dijit/layout/ContentPane" data-dojo-attach-point="ddContent">
<select data-dojo-attach-point="multiSelect" data-dojo-type="libs/hntb/dijits/FilterableCheckedMultiSelect/FilterableCheckedMultiSelect"></select>
</div>
</div>
</button>
</div>