Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>{!$Component.[elementid]}</code> doesn't always work for me; I'm not sure why. I prefer to use the Attribute Ends With Selector (<a href="http://api.jquery.com/attribute-ends-with-selector/" rel="nofollow">http://api.jquery.com/attribute-ends-with-selector/</a>). </p> <p>Try something like this:</p> <pre><code>&lt;apex:includeScript value="/soap/ajax/18.0/connection.js" /&gt; &lt;apex:includeScript value="/soap/ajax/18.0/apex.js" /&gt; &lt;script&gt; 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; } &lt;/script&gt; &lt;apex:form &gt; &lt;apex:pageblock &gt; &lt;apex:pageblocksection &gt; &lt;apex:pageblocksectionitem &gt; &lt;apex:inputfield id="myInput" value="{!Contact.FirstName}" /&gt; &lt;/apex:pageblocksectionitem&gt; &lt;/apex:pageblocksection&gt; &lt;/apex:pageblock&gt; &lt;/apex:form&gt; </code></pre> <p>Controller:</p> <pre><code>global class TestAutocomplete { global TestAutocomplete(ApexPages.StandardController myStandardController) {} webservice static List&lt;String&gt; 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&lt;String&gt; mySourceList = mySourceText.split(' '); List&lt;String&gt; myReturnList = new List&lt;String&gt;(); for(String s : mySourceList) { if(s.contains(SearchTerm)){ myReturnList.add(s); } } return myReturnList; } } </code></pre> <p>Hope that helps,<br/> Matt</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload