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
sapthagiri_186sapthagiri_186 

Can we have 2 onclick events or 2 action functions in a single command link

Hello everyone,

 

I have got a requirement where there is a list of records in a table, so when clicked on any row, then an action should perform showing its subsequent records in another table and at the same time if clicked on the value in the table row, then page should redirect to another page where it displays the value's overview.

 

I did get one of the above mentioned functionality, like when clicked on the value in the table row, the page gets redirected to its overview page.

 

So, is it possible to hvae 2 onclick events or 2 action function for a single command link.

 

Best Regards

DaveHDaveH

Well if you're trying to stay with a pure Visualforce solution (no jQuery) then you will have to implement a sort of event delegation in an action function. Some pseudo code is below.

 

- User clicks command link

- In javascript check to see if the link that the user clicked is equal to the last link that the user clicked

-- If last link is equal to the clicked link that means the user clicked it twice so redirect to overview page

-- If last link is not equal to the clicked link OR last link is NULL display table for clicked link

 

- Register clicked link as the last link element clicked

 

Make sense?

Subha ASubha A

 to There is no need of 2 events or action functions. All need to do is you can have different page blocks and based on the selection need to update/rerender the pageblocks which show you the data that is required

Subha ASubha A

There is no need of 2 events or action functions. All need to do is you can have different page blocks and based on the selection need to update/rerender the pageblocks which show you the data that is required