インクリメントサーチで defaultValue をみて検索条件の変更を判定する

(function($j){
	$j.incrementSearch = function(callback){
		this.exec=callback;
		this.timer=null;
	}
	$j.extend($j.incrementSearch.prototype,{
		queue : function(target){
			var o=this;
			if(o.timer)clearTimeout(o.timer);
			o.timer = setTimeout(function(){
				if(o.isChange(target))
					o.exec()
			},500)
		},
		isChange : function(target){
			var buf=target.data('prev')
			var val=target.val();
			if(buf==undefined){
				target.data('prev',val);
				//初回時はdefaultValueで値の変更を判定
				return target.attr('defaultValue')!=val;	
			}
			//2回目以降はキャッシュで判定
			target.data('prev',val);
			return buf != val;
		}
	});
})(jQuery);

jQuery(function($j){
	var search=new $j.incrementSearch(function(){
		//検索ロジック
	});

	//event.targetで検索条件の入力を参照
	$j('#search-content').keyup(function(evt){
		var target=$j(evt.target);
		if(target.attr('tagName')=='INPUT')search.queue(target);
	});
});