assertion failed in ItemFileWriteStore

阅读更多
Discovery.fullFillCombo = function(comboId,options,setDefault){
	var targetCombo =  dijit.byId(comboId);  
	
	var comboOptions = new dojo.data.ItemFileWriteStore({data: {identifier: 'name', items:[]}});
	
 	if(targetCombo.store!=null){
 		targetCombo.store==null;
 	}
	for (var i in options) {
		var tmpOption = options[i];
		comboOptions.newItem({name: tmpOption});		
		comboOptions.save({onComplete: this.saveOptionComplete, onError: this.saveOptionError});
	}
	targetCombo.store = comboOptions;
	if(setDefault == 'true'){
		targetCombo.attr('value', options[0]);
	}
};
Discovery.saveOptionComplete = function() {
	console.log("SAVE COMPLETE");
	
};
Discovery.saveOptionError = function() {
	console.log("SAVE ERROR");
};

上面代码是实现动态添加combo option的。
当出现assertion failed in ItemFileWriteStore异常时,检查下添加的option是否有重复的

你可能感兴趣的:(dojo)