Skip to content

Instantly share code, notes, and snippets.

@zokito
Forked from msrivastav13/JqueryAutocomplete
Created October 25, 2013 13:59
Show Gist options
  • Save zokito/7155137 to your computer and use it in GitHub Desktop.
Save zokito/7155137 to your computer and use it in GitHub Desktop.
<apex:page controller="MyJSController">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.MyJSController.getAccount}',
function(result, event){
if (event.status) {
var availableTags = [];
availableTags=result;
// alert('availableTags'+availableTags);
$( "#tags" ).autocomplete({
source: availableTags
});
} else if (event.type === 'exception') {
} else {
}
},
{escape: true}
);
});
</script>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags" />
</div>
</apex:page>
global with sharing class MyJSController {
public String accountName { get; set; }
public static Account account { get; set; }
public MyJSController() { } // empty constructor
@RemoteAction
global static List<String> getAccount() {
List<String> accname=new List<String>();
List<Account> lstaccount = [SELECT id, name, phone, type, numberofemployees FROM
Account];
for( Account acc:lstaccount){
accname.add(acc.name);
}
return accname;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment