{!$Component.[elementid]}
не всегда работает для меня;Я не уверен почему.Я предпочитаю использовать Конец атрибута с селектором (http://api.jquery.com/attribute-ends-with-selector/).
Попробуйте что-то вроде этого:
<apex:includeScript value="/soap/ajax/18.0/connection.js" />
<apex:includeScript value="/soap/ajax/18.0/apex.js" />
<script>
var j$ = jQuery.noConflict();
j$(document).ready(function(){init();});
function init()
{
var mySourceText = "ActionScript AppleScript Asp BASIC C "
+ "C++ Clojure COBOL ColdFusion Erlang Fortran Groovy "
+ "Haskell Java JavaScript Lisp Perl PHP Python Ruby "
+ "Scala Scheme";
var mySource = mySourceText.split(" ");
j$("[id$='myInput']").autocomplete({
minLength: 2,
autoFocus: true,
source: function(request, response){
response(GetSourceAjaxAPI(request.term)); }
});
}
function GetSourceAjaxAPI(s)
{
var result = sforce.apex.execute("TestAutocomplete",
"GetAutocompleteValuesAjaxAPI", {SearchTerm:s});
return result;
}
</script>
<apex:form >
<apex:pageblock >
<apex:pageblocksection >
<apex:pageblocksectionitem >
<apex:inputfield id="myInput" value="{!Contact.FirstName}" />
</apex:pageblocksectionitem>
</apex:pageblocksection>
</apex:pageblock>
</apex:form>
Контроллер:
global class TestAutocomplete
{
global TestAutocomplete(ApexPages.StandardController myStandardController) {}
webservice static List<String>
GetAutocompleteValuesAjaxAPI(String SearchTerm)
{
String mySourceText = 'ActionScript AppleScript Asp BASIC C '
+ 'C++ Clojure COBOL ColdFusion Erlang Fortran Groovy '
+ 'Haskell Java JavaScript Lisp Perl PHP Python Ruby '
+ 'Scala Scheme';
List<String> mySourceList = mySourceText.split(' ');
List<String> myReturnList = new List<String>();
for(String s : mySourceList)
{
if(s.contains(SearchTerm)){ myReturnList.add(s); }
}
return myReturnList;
}
}
Надеюсь, что поможет,Matt