Help get this topic noticed by sharing it on
Twitter,
Facebook, or email.
Twitter,
Facebook, or email.
PageAction OnClick Listener gets called multiple times if page is reloaded.
I have implemented a pageaction with with an onclick listener that runs some code. My issue is if the page gets reloaded multiple onclick listeners get placed and will get called multiple times. How do I fix this?
-
Hello Plinpod,
I understand that you are having an issue with appAPI.pageAction.onClick. Usually, this works without problems and hence in order to assist further I need to take a closer look.
Therefore, please provide as much of the following information as possible and I will investigate:
- The extension id
- The file/line number where the code snippet can be found
- Which browser and operating system you are testing on, including version numbers
- The exact steps for reproducing the problem
- Any additional useful data, such as URLs, screenshots, videos, ...
-
-
Super easy to replicate the issue. And I only tested this in Chrome.
Just this code will do it.
appAPI.ready(function($) {
appAPI.pageAction.setPages({
pages: ["*.google.com/*", /^http\:\/\/twitter\.com/],
iconResourcePath:'icons/icon.jpg',
callback: function(){
console.log('Page Action button clicked');
}
});
});
same happens if you just use setResourceIcon and the onClick function.
But with that code when you go to the page it works, but for each reload it adds an extra listener and the callback function gets called an extra time for each page reload. So if I reload the page 10 times and don't close the tab, that callback function will get executed 10 times.
- So setup extension with that code.
- Click Page Action Button.
- Check Console for the log text.
- Reload the page.
- Click Page Action Button
- Check Console for the log text and notice that it fired twice this time.
etc etc
I changed my extension code a bunch of times and it does different things now I don't think it would be much help to fix this specific error. -
-
Hello Plinpod,
Thanks ... I reproduced the scenario and have escalated it to the dev team to investigate. -
-
Hi Shlomo,
this issue was raised 10 months ago but still appears to be happening. Can you please advise what the outcome was of the dev team investigation.-
Hi Ian, currently there is no further update on this issue.
-
-
-
-
Loading Profile...




EMPLOYEE

