-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoCompleteAccount.vfc
47 lines (42 loc) · 1.93 KB
/
AutoCompleteAccount.vfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<apex:component controller="AutoCompleteComponentController">
<apex:stylesheet value="{!URLFOR($Resource.AutoComplete,'/jquery-ui.css')}"/>
<apex:includeScript value="{!URLFOR($Resource.AutoComplete,'/jquery-1.12.4.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.AutoComplete,'/jquery-ui.js')}"/>
<apex:pageBlockSection collapsible="false" title="Search Account" >
<input id="accountSearch" value="{!searchTerm}" />
</apex:pageBlockSection>
<script>
$(function(){
$("#accountSearch").autocomplete({
minLength: 2,
source: function(request, response){
var searchString = request.term;
Visualforce.remoting.Manager.invokeAction("{!$RemoteAction.AutoCompleteComponentController.getSearchSuggestions}",searchString,function(result,event){
if(event.status){
if(typeof result === 'undefined' || result.length <=0){
response(['No Record Found']);
}else {
response(result);
}
}else {
response([]);
}
},
{escape: true}
);
},
select: function(event, ui){
if(ui.item.label != 'No Record Found'){
$("#accountSearch").val(ui.item.label);
showAccountDetail(ui.item.value);
}
return false;
},
focus: function( event, ui ) {
$("#accountSearch").val(ui.item.label);
return false;
}
});
});
</script>
</apex:component>