Subversion Repositories SmartDukaan

Rev

Rev 24176 | Rev 24271 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24176 Rev 24191
Line 432... Line 432...
432
	
432
	
433
}
433
}
434
function getItemAheadOptions(jqElement, callback) {
434
function getItemAheadOptions(jqElement, callback) {
435
	jqElement.typeahead('destroy').typeahead({
435
	jqElement.typeahead('destroy').typeahead({
436
		source: function(q, process) {
436
		source: function(q, process) {
437
			if(q.length <= 2) {
437
			if(q.length <= 3) {
438
				console.log("Query is empty");
438
				if(typeof queryData != "undefined") {
-
 
439
					queryData = undefined;
-
 
440
				}
439
				return;
441
				return;
440
			} else {
442
			} else if (q.length > 3 && typeof queryData == "undefined"){
441
				return $.ajax(context+"/item", {
443
				return $.ajax(context+"/item", {
442
					global:false,
444
					global:false,
443
					data: {query : q}, 
445
					data: {query : q}, 
444
					success: function(data){
446
					success: function(data){
445
						console.log(data);
447
						queryData = JSON.parse(data);
446
						process(JSON.parse(data));
448
						process(queryData);
447
					},
449
					},
448
				});
450
				});
-
 
451
			} else {
-
 
452
				return process(queryData);
449
			}
453
			}
-
 
454
			return;
450
		},
455
		},
451
		delay: 400,
456
		delay: 400,
452
		items: 20,
457
		items: 20,
453
		displayText: function(item){return item.itemDescription;},
458
		displayText: function(item){return item.itemDescription;},
454
		autoSelect: true,
459
		autoSelect: true,