Javascript 道场。将JSon中的属性设置为HTML属性
我有Javascript 道场。将JSon中的属性设置为HTML属性,javascript,html,dojo,Javascript,Html,Dojo,我有dojox.form.CheckedMultiSelect: <span dojoType="dojo.data.ItemFileReadStore" url="..." jsId="listStore"></span> <select id="unsubscribedList" class="soria" dojoType="dojox.form.CheckedMultiSelect" multiple="true" onchange="..." store
dojox.form.CheckedMultiSelect
:
<span dojoType="dojo.data.ItemFileReadStore" url="..." jsId="listStore"></span>
<select id="unsubscribedList" class="soria" dojoType="dojox.form.CheckedMultiSelect"
multiple="true" onchange="..." store="listStore" title="title"></select>
如何将JSon中的“items.title
”属性设置为将为CheckedMultiSelect
创建的每个复选框的HTML属性“title”
dojo.ready(function() {
// 1.7.2 template has 'dojoxCheckedMultiSelectHidden' className on its select from template.
// if this is different (inspect your DOM after onload), adapt the query selector
var opts = dojo.query('.dojoxCheckedMultiSelectHidden option'),
store = dijit.byId('listStore');
store.fetch({ onComplete: function(items) {
for(var i = 0; i < items.length; i++) {
if(!opts[i]) continue;
else opts[i].title = store.getValue(items[i], 'title');
}
}});
});
试试这个:
dojo.ready(function() {
// 1.7.2 template has 'dojoxCheckedMultiSelectHidden' className on its select from template.
// if this is different (inspect your DOM after onload), adapt the query selector
var opts = dojo.query('.dojoxCheckedMultiSelectHidden option'),
store = dijit.byId('listStore');
store.fetch({ onComplete: function(items) {
for(var i = 0; i < items.length; i++) {
if(!opts[i]) continue;
else opts[i].title = store.getValue(items[i], 'title');
}
}});
});
怎么样?有问题吗?还是你把它们整理好了?怎么样?你有问题吗?还是你已经解决了?
// array with indexes matching the options from markup
var titles = [ "title1", "title2", "title3" ];
dojo.addOnLoad(function() {
// note, that the '_0' is a generic ID, config options are not accepting the id attribute either
// calling private function, again not correctly layed out
var childObjects = dijit.byId('dojox_form_CheckedMultiSelect_0')._getChildren();
dojo.forEach(childObjects, function(optObject, index) {
optObject.labelNode.title = titles[index];
});
});