How to remove Listener

Hi read the API docs that contains removeActionCompleteListener but it seems that it doesnt work. Here’s how I tried to remove a listener


    function callBackFecharDecVenda(commandID) { 	


Can you provide me some working example


There is a more reliable way of removing listeners other than just removing the first in the list. Obtain a reference to the call back function like this:

function doSomething(){ 
//Your logic 

//add a reference

//remove the reference

Hope this helps.


I´ve tried what you wrote and It doesn’t work.

If you press the button it will refresh the area that contains the script that adds and removes the listener. As the listener is never remover for each time the area is refreshed you will see +1 alert dialog

Thanks (14.9 KB)

Hi Herve,

You will want to store the function object in some global variable so you use the same reference when adding and removing. What your test portlet is doing is redeclaring the function every time the page fragment is rendered, so it is using different function references on each render.

For example, do something like this:

//remove the previous reference 

//re-declare the function and store it on the window object
window.doSomethingFn = function(){ 

//add a reference 

Thanks for the test project. I think the problem you’re having is that you have attached an Action Complete Listener to a button, but that Listener “lives” inside of a Panel that is being refreshed upon completion.

Is it possible to have that Javascript live outside of the panel that is being refreshed?

In my case I can not put the script outside the refreshed area.

I’ve tried the script that was suggested and It also contains the problem.

I thing that the API implementation should contains some problem because if I also try to get the listeners added the response is also null or 0

I’m facing the same problem currently with version 7.1.3.
I’ve tried the proposed solutions, but unfortunately with no success.
The previously registered listeners could not be removed, resulting in multiple executin of the same logic.
So I am curious, did you manage to find a workaround for this issue?