visualforce-typeahead icon indicating copy to clipboard operation
visualforce-typeahead copied to clipboard

Update to support actionSupport with event=onchange

Open thvd opened this issue 11 years ago • 5 comments

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

thvd avatar Sep 10 '14 13:09 thvd

Sorry, this is not going to work. We should think about some other solution.

thvd avatar Sep 10 '14 15:09 thvd

Why didn't it work?

groundwired avatar Sep 10 '14 15:09 groundwired

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.

thvd avatar Sep 10 '14 15:09 thvd

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.

groundwired avatar Sep 10 '14 19:09 groundwired

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>

thvd avatar Sep 11 '14 09:09 thvd