ITeye博客

autocomplete

giga_Zhang · 2012-01-30 13:41 · JavaScript · Web前端 · Markdown

$("#department").autocomplete('/oms/orgAjax/getSimilarNames', { width: 162, minChars: 2, dataType: 'json', highlight: false, scroll: true, scrollHeight: 300, parse: function(data) { var array = new Array(); for(var i = 0 ; i < data.orgNames.length; i++){ array = {data: data.orgNames*, value: data.orgNames*, result: data.orgNames*}; } return array; }, formatItem: function(row){ return row; }, onReSelect: function(options) { alert("reselect" + options); return options; } }).result(function(event, item) { alert("result" + item); });;

自定义事件onReSelect,在源码中添加如下代码: function onChange(crap, skipPrevCheck) { if (options.onReSelect) { var op = options.onReSelect(options); if (op) { $.extend(options, op); } }

	if( lastKeyPressCode == KEY.DEL ) {
		select.hide();
		return;
	}
	
	var currentValue = $input.val();
	
	if ( !skipPrevCheck && currentValue == previousValue )
		return;
	
	previousValue = currentValue;
	
	currentValue = lastWord(currentValue);
	if ( currentValue.length >= options.minChars) {
		$input.addClass(options.loadingClass);
		if (!options.matchCase)
			currentValue = currentValue.toLowerCase();
		request(currentValue, receiveData, hideResultsNow);
	} else {
		stopLoading();
		select.hide();
	}
};

http://jquery.sanchezsalvador.com/page/jquerycombobox.aspx

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。