0
我想用JavaScript來獲取dijit元素類型。例如如果該項目是文本框,組合框,過濾選擇等。這是我試過的,並導致undefined被返回。Dojo獲取元素類型
HTML
<s:textfield type="text" id="name" required="true" data-dojo-type="dijit/form/ValidationTextBox" />
<s:select id="gender" data-dojo-type="dijit/form/FilteringSelect" />
的Javascript
var genderType = dijit.byId('gender').attr('data-dojo-type');
var name= dijit.byId('name').attr('data-dojo-type');
console.log(genderType);
console.log(name);
結果
undefined
undefined
你能提供jsfiddle嗎? – IProblemFactory
試試這種方式:'var yourWidgetType = dojo.filter(dijit.registry._hash,function(widget){ return widget.declaredClass; })' – user3241019
@ user3241019它沒有返回任何結果 – devdar