⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 combobox.js

📁 dojo与json创建无限级树的时候,当在父结点下添加了一个新结点,我怎么让父亲结点重新调用json加载一下子结点内容.
💻 JS
📖 第 1 页 / 共 2 页
字号:
		highlightPrevOption: function(){			if(this._highlighted_option && this._highlighted_option.previousSibling){				this.focusOptionNode(this._highlighted_option.previousSibling);			}else{				this._highlighted_option = null;				this.hideResultList();				return;			}			this.scrollIntoView();		},			itemMouseOver: function(evt){			this.focusOptionNode(evt.target);			dojo.html.addClass(this._highlighted_option, "dojoComboBoxItemHighlight");		},			itemMouseOut: function(evt){			this.blurOptionNode();		},			fillInTemplate: function(args, frag){			// FIXME: need to get/assign DOM node names for form participation here.			this.comboBoxValue.name = this.name;			this.comboBoxSelectionValue.name = this.name+"_selected";				var source = this.getFragNodeRef(frag);			dojo.html.copyStyle(this.domNode, source);				var dpClass;			if(this.mode == "remote"){				dpClass = dojo.widget.incrementalComboBoxDataProvider;			}else if(typeof this.dataProviderClass == "string"){				dpClass = dojo.evalObjPath(this.dataProviderClass)			}else{				dpClass = this.dataProviderClass;			}			this.dataProvider = new dpClass();			this.dataProvider.init(this, this.getFragNodeRef(frag));				// Prevent IE bleed-through problem			this.optionsIframe = new dojo.html.BackgroundIframe(this.optionsListWrapper);			this.optionsIframe.size([0,0,0,0]);		},				focus: function(){			// summary			//	set focus to input node from code			this.tryFocus();		},			openResultList: function(results){			this.clearResultList();			if(!results.length){				this.hideResultList();			}				if(	(this.autoComplete)&&				(results.length)&&				(!this._prev_key_backspace)&&				(this.textInputNode.value.length > 0)){				var cpos = this.getCaretPos(this.textInputNode);				// only try to extend if we added the last character at the end of the input				if((cpos+1) > this.textInputNode.value.length){					// only add to input node as we would overwrite Capitalisation of chars					this.textInputNode.value += results[0][0].substr(cpos);					// build a new range that has the distance from the earlier					// caret position to the end of the first string selected					this.setSelectedRange(this.textInputNode, cpos, this.textInputNode.value.length);				}			}				var even = true;			while(results.length){				var tr = results.shift();				if(tr){					var td = document.createElement("div");					td.appendChild(document.createTextNode(tr[0]));					td.setAttribute("resultName", tr[0]);					td.setAttribute("resultValue", tr[1]);					td.className = "dojoComboBoxItem "+((even) ? "dojoComboBoxItemEven" : "dojoComboBoxItemOdd");					even = (!even);					this.optionsListNode.appendChild(td);					dojo.event.connect(td, "onmouseover", this, "itemMouseOver");					dojo.event.connect(td, "onmouseout", this, "itemMouseOut");				}			}				// show our list (only if we have content, else nothing)			this.showResultList();		},			onFocusInput: function(){			this._hasFocus = true;		},			onBlurInput: function(){			this._hasFocus = false;			this._handleBlurTimer(true, 500);		},			// collect all blur timers issues here		_handleBlurTimer: function(/*Boolean*/clear, /*Number*/ millisec){			if(this.blurTimer && (clear || millisec)){				clearTimeout(this.blurTimer);			}			if(millisec){ // we ignore that zero is false and never sets as that never happens in this widget				this.blurTimer = dojo.lang.setTimeout(this, "checkBlurred", millisec);			}		},			// these 2 are needed in IE and Safari as inputTextNode loses focus when scrolling optionslist		_onMouseOver: function(evt){			if(!this._mouseover_list){				this._handleBlurTimer(true, 0);				this._mouseover_list = true;			}		},			_onMouseOut:function(evt){			var relTarget = evt.relatedTarget;			if(!relTarget || relTarget.parentNode!=this.optionsListNode){				this._mouseover_list = false;				this._handleBlurTimer(true, 100);				this.tryFocus();			}		},			_isInputEqualToResult: function(result){			input = this.textInputNode.value;			if(!this.dataProvider.caseSensitive){				input = input.toLowerCase();				result = result.toLowerCase();			}			return (input == result);		},		_isValidOption: function(){			tgt = dojo.dom.firstElement(this.optionsListNode);			isValidOption = false;			while(!isValidOption && tgt){				if(this._isInputEqualToResult(tgt.getAttribute("resultName"))){					isValidOption = true;				}else{					tgt = dojo.dom.nextElement(tgt);				}			}			return isValidOption;		},		checkBlurred: function(){			if(!this._hasFocus && !this._mouseover_list){				this.hideResultList();				// clear the list if the user empties field and moves away.				if(!this.textInputNode.value.length){					this.setAllValues("", "");					return;				}								isValidOption = this._isValidOption();				// enforce selection from option list				if(this.forceValidOption && !isValidOption){					this.setAllValues("", "");					return;				}				if(!isValidOption){// clear					this.setSelectedValue("");				}			}		},			sizeBackgroundIframe: function(){			var w = dojo.style.getOuterWidth(this.optionsListNode);			var h = dojo.style.getOuterHeight(this.optionsListNode);			if( w==0 || h==0 ){				// need more time to calculate size				dojo.lang.setTimeout(this, "sizeBackgroundIframe", 100);				return;			}			if(this._result_list_open){				this.optionsIframe.size([0,0,w,h]);			}		},			selectOption: function(evt){			var tgt = null;			if(!evt){				evt = { target: this._highlighted_option };			}				if(!dojo.dom.isDescendantOf(evt.target, this.optionsListNode)){				// handle autocompletion where the the user has hit ENTER or TAB					// if the input is empty do nothing				if(!this.textInputNode.value.length){					return;				}				tgt = dojo.dom.firstElement(this.optionsListNode);					// user has input value not in option list				if(!tgt || !this._isInputEqualToResult(tgt.getAttribute("resultName"))){					return;				}				// otherwise the user has accepted the autocompleted value			}else{				tgt = evt.target; 			}				while((tgt.nodeType!=1)||(!tgt.getAttribute("resultName"))){				tgt = tgt.parentNode;				if(tgt === document.body){					return false;				}			}				this.textInputNode.value = tgt.getAttribute("resultName");			this.selectedResult = [tgt.getAttribute("resultName"), tgt.getAttribute("resultValue")];			this.setAllValues(tgt.getAttribute("resultName"), tgt.getAttribute("resultValue"));			if(!evt.noHide){				this.hideResultList();				this.setSelectedRange(this.textInputNode, 0, null);			}			this.tryFocus();		},			clearResultList: function(){			var oln = this.optionsListNode;			while(oln.firstChild){				dojo.event.disconnect(oln.firstChild, "onmouseover", this, "itemMouseOver");				dojo.event.disconnect(oln.firstChild, "onmouseout", this, "itemMouseOut");				oln.removeChild(oln.firstChild);			}		},			hideResultList: function(){			if(this._result_list_open){				this._result_list_open = false;				this.optionsIframe.size([0,0,0,0]);				dojo.lfx.fadeHide(this.optionsListNode, this.fadeTime).play();			}		},			showResultList: function(){			// Our dear friend IE doesnt take max-height so we need to calculate that on our own every time			var childs = this.optionsListNode.childNodes;			if(childs.length){				var visibleCount = this.maxListLength;				if(childs.length < visibleCount){					visibleCount = childs.length;				}					with(this.optionsListNode.style){					display = "";					height = ((visibleCount) ? (dojo.style.getOuterHeight(childs[0]) * visibleCount) : 0)+"px";					width = dojo.html.getOuterWidth(this.cbTableNode)-2+"px";				}				// only fadein once (flicker)				if(!this._result_list_open){					dojo.html.setOpacity(this.optionsListNode, 0);					dojo.lfx.fadeIn(this.optionsListNode, this.fadeTime).play();				}								// prevent IE bleed through				this._iframeTimer = dojo.lang.setTimeout(this, "sizeBackgroundIframe", 200);				this._result_list_open = true;			}else{				this.hideResultList();			}		},			handleArrowClick: function(){			this._handleBlurTimer(true, 0);			this.tryFocus();			if(this._result_list_open){				this.hideResultList();			}else{				this.startSearchFromInput();			}		},			tryFocus: function(){			try {				this.textInputNode.focus();			} catch (e) {				// element isn't focusable if disabled, or not visible etc - not easy to test for.	 		};		},				startSearchFromInput: function(){			this.startSearch(this.textInputNode.value);		},			postCreate: function(){			dojo.event.connect(this, "startSearch", this.dataProvider, "startSearch");			dojo.event.connect(this.dataProvider, "provideSearchResults", this, "openResultList");			dojo.event.connect(this.textInputNode, "onblur", this, "onBlurInput");			dojo.event.connect(this.textInputNode, "onfocus", this, "onFocusInput");				var s = dojo.widget.html.stabile.getState(this.widgetId);			if (s) {				this.setState(s);			}		}	});

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -