function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
heuyeheuye 

actionfunction and actionstatus work incorrectly in component

when i use actionfunction and actionstatus in component, and then put two components in a page,it seems the actionfunction and actionstatus works strangely.

 

it seems component A calls actionfunction in component B.maybe there is a confliction and one of them doesn't work.

 

anyone met this problem,is there a workaround?

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

WRT actionFunction,  you are defining a javascript function with a given name.   If you have the same name in two components, or use the same component twice in the page, you are going to end up with a page that contains two definitions of the function.   Whichever one occurs last in the page is going to override the first.  That's just the way javascript in a page works.

 

The workaround for this situation is to make sure it doesn't matter by having the function identical is both places and using function parmeters to distinguish whatever cases are needed. 

 

 

All Answers

bob_buzzardbob_buzzard

I have seen a similar post some time ago (probably 1-2 years ago) that was around duplicate actionpoller components interfering with each other.

 

I've been trying to find the original post without success.  I have a vague recollection that the solution was to put each component in its own actionregion, but I can't say for sure that was it.

aballardaballard

WRT actionFunction,  you are defining a javascript function with a given name.   If you have the same name in two components, or use the same component twice in the page, you are going to end up with a page that contains two definitions of the function.   Whichever one occurs last in the page is going to override the first.  That's just the way javascript in a page works.

 

The workaround for this situation is to make sure it doesn't matter by having the function identical is both places and using function parmeters to distinguish whatever cases are needed. 

 

 

This was selected as the best answer
heuyeheuye

thanks for your answer,

this is another problem in my code,i didn't consider this before--two actions interfering with each other.