Open thvd opened 10 years ago
Sorry, this is not going to work. We should think about some other solution.
Why didn't it work?
I tried the following:
<c:Typeahead searchBoxId="templateSearch" object="Template__c" destinationForSelectedId="templateId" destinationForSelectedValue="templateName" />
<apex:inputHidden id="templateId" value="{!templateId}">
<apex:actionSupport event="onchange" action="{!fetchTemplate}" rerender="linkPanel"/>
</apex:inputHidden>
But when I added the .change()
call to the JavaScript it did not trigger the fetchTemplate
actionSupport action.
The top item on my list of possible improvements is to add an optional parameter to the component called onSelection or selectionAction or something like that. I had thought that would be a javascript function (which could in turn call an actionFunction to run apex) but it could possibly be an apex method. I think this would accomplish what you want.
Afraid I don't have time to take it on right now, but will keep it in the backlog.
This morning I did some further research and found that using a non-hidden <apex:inputText>
works.
Example:
<apex:inputText id="templateId" value="{!templateId}" style="display: none;">
<apex:actionSupport event="onchange" action="{!fetchTemplate}" reRender="linkPanel"/>
</apex:inputText>
You can now support the onchange event. For reference see: http://stackoverflow.com/questions/2026704/what-event-can-be-captured-when-an-html-hidden-input-value-is-set-changed