question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

handleUpload($event) gets triggerd twice

See original GitHub issue

Hi,

I’m using the more “advanced” way of your ngx-uploader. So I have the autoUpload set to false. And when I click a button, I trigger the startUpload event. The thing is, the handleUpload method is triggered twice… I have no idea why this is happening to be honest.

The code I’m using is almost exact the same as your example.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
maartentibaucommented, Feb 24, 2017

OK, I figured out what’s actually causing these multiple uploads. I haven’t looked into the source code, but to trigger multiple uploaded… just try this.

  1. select a file
  2. select another file
  3. select yet another file
  4. Yes… you guessed it… select another file

Then click on your upload button, you’ll notice multiple uploads being fired. So… for some reason the “select a file” events are being stored and on upload all fired again, pretty strange behavior.

Gonna look into the source code after this weekend trying to figure out how to solve this. Keep you guys posted.

1reaction
lukasz-galkacommented, Feb 28, 2017

For me this method is always triggered many times and how many depends on file size. As you can see below this method is also triggered during upload with %, not only at the end (success/error)

handleUpload(data: any): void {

  console.log('handleUpload');

  if (data && data.response === '') {
    console.log('error');
  } else if (data && data.response) {
    console.log('success');
  }

  console.log(data.progress.percent);
}

and output from console:

handleUpload
43
handleUpload
73
handleUpload
100
handleUpload
success
100
Read more comments on GitHub >

github_iconTop Results From Across the Web

File input triggers change event twice (or more) - Stack Overflow
When you click on the #holder a file explorer pops up. But selecting a file triggers the console.log() line to be executed twice...
Read more >
Triggered twice - When an event is added, updated
Hi, When an event is created (via OWA) in a calendar, the "When an event is added, updated or deleted (V3)" event is...
Read more >
Click event triggering twice. #4101 - JedWatson/react-select
Appears that I am getting an error in the console: [Intervention] Unable to preventDefault inside passive event listener due to target being ...
Read more >
Event and Business obejct triggered twice - SAP Community
The event TERMINATE_WORKFLOW and Business object APPR_DOC is triggered.My issue is it is getting triggred twice.So when i link my workf.
Read more >
'select' event triggered automatically, and twice - jQWidgets
... able to determine), the 'select' event is triggered automatically immediately after populating the list, and is also triggered twice.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found