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.

Toastr not firing multiple times.

See original GitHub issue

Hello,

When I got something like this

function send(form) {
      elearningMessage.Create({
        text: vm.message,
        conversation_id: vm.conversation.id
      }).then(function (response) {
        if (response.success !== false) {
          vm.conversation.messages.push(response);

          vm.message = undefined;
          form.$setPristine();

          toastr.error('Meee');
          toastr.success('Message sent');
        } else {
          toastr.error(response.error);
        }
      });
    }

Exact lines:

toastr.error('Meee');
toastr.success('Message sent');

Above toastr will fire each message sent with two popups.

Below toastr will fire only once when I would get an error message but only once initial, not every time when my request will go with error.

toastr.error(response.error);

???

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
n2sandhucommented, Feb 19, 2016

@tskorupka : found the solution to the issue. It says in the documention that by default toastr is configured to allow duplicates of previously show toasts, but apparently something is going wrong there. So all that needs to be done is put this bit of code in your application and it would work.

app.config(function(toastrConfig) {
  angular.extend(toastrConfig, {
    autoDismiss: false,
    containerId: 'toast-container',
    maxOpened: 0,    
    newestOnTop: true,
    positionClass: 'toast-top-right',
    preventDuplicates: false,
    preventOpenDuplicates: false,
    target: 'body'
  });
});
0reactions
tskorupkacommented, Feb 19, 2016

That explains everything, thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Duplicate toastr error messages - Stack Overflow
The code is to check whether there are existing error toastr which has the same message being displayed. I will only fire the...
Read more >
jQuery Toast Plugin
Note Hit the run button multiple times to test these demos. 7. Positioning the toast. position property can be used to specify the...
Read more >
Lightning toastEvent firing twice - how to avoid
Hi, We have a lighting component opens through quick action popup. After finishing the task we are refreshing the record detail page, ...
Read more >
Toasts - Bootstrap
Toasts will automatically hide if you do not specify autohide: false . Examples. Basic. To encourage extensible and predictable toasts, we recommend a...
Read more >
How to Create Angular Toastr Notifications - JScrambler Blog
No other part of the application needs any change. Customizing The Toast Notification. ngx-toastr provides a number of options to customize the ...
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