function autoSearch(searchElementId, linkDomain) { $j(document).ready(function() { if($j( "#" + searchElementId) != undefined && $j( "#" + searchElementId) != null) { $j( "#" + searchElementId).autocomplete({ source: function( request, response ) { $j.ajax({ url: linkDomain + "/esignalprod/feed/search", dataType: "jsonp", data: { s: request.term }, success: function( data ) { response( $j.map( data.results, function( item ) { return { label: item.t + (item.d ? " - " + item.d : ""), value: item.t, type: item.type } })); } }); }, minLength: 1, highlightItem: true, select: function( event, ui ) { document.location.href = linkDomain + "/esignalprod/quote.action?s=" + ui.item.value+ "&type=" + ui.item.type + "&fromSearch=true"; }, open: function() { $j( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" ); }, close: function() { $j( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" ); } }); } }); }