0
代碼片段:
var role=s[0].Role;// role contains string value
dijit.byId("editRole").attr("Value",getRoleByName(role));
function getRoleByName(role)
{
var roleVal;
alert(role);
switch(role)
{
case 'Basic User' :roleVal='1';break;
case 'Network Operator' :roleVal='3';break;
case 'System Administrator' :roleVal='5';break;
case 'Custom Level 1' :roleVal='11';break;
case 'Custom Level 2' : roleVal='12';break;
default: roleVal='1';break;
}
return roleVal;
}
當我試着打電話給其在它的switch語句,我在IE8中得到以下錯誤的JavaScript方法,但在FF工作正常..開關的情況下沒有在IE8工作
錯誤在開發工具:
method Error executing: function(/*Event*/ e){
// summary:
// Handler when the user activates the button portion.
if(this._onClick(e) === false){ // returning nothing is same as true
e.preventDefault(); // needed for checkbox
} else if (this.type == "submit" && !this.focusNode.form){ // see if a nonform widget needs to be signalled
for(var node=this.domNode; node.parentNode/*#5935*/; node=node.parentNode){
var widget=dijit.byNode(node);
if(widget && typeof widget._onSubmit == "function"){
widget._onSubmit(e);
break;
}
}
}
}TypeError: Object doesn't support this property or method
誰能幫助我? ......如何解決這個問題?... 在此先感謝
問候, Kamesh
我看不到任何tidles實現... – starbeamrainbowlabs 2012-07-21 15:04:05
感謝迅速的反應mschr ......你是right..actually問題是即時通訊使用role.toString( )。修剪()。這是造成問題......但如果我刪除toString轉換,總是返回默認值。 – kamesh 2012-07-21 15:36:37
修剪不是一個完全原生的實現功能,虐待添加一個字符串原型擴展到我的答案然後 – mschr 2012-07-21 15:46:51