0

I'm using Angular toaster messages. I use toaster.clear('*') to clear a toaster message and show the next toaster message. This works fine in my other situations.

However here it does not work. I clear the previous toaster message and change the text of the toaster, but the message changes only when I hover over it.

$("#pageColorPallette").change(function() {
  if ($scope.questionNumber == 1) {
    selectedcoler = $("#pageColorPallette").spectrum("get");
    selectedhexacoler = selectedcoler.toHexString();
    toaster.clear('*');
    var content = document.getElementById("editableTextArea");
    content.style.backgroundColor = selectedhexacoler;
    if (selectedhexacoler == '#ffffff') {
      if ($scope.attempts < 3) {
        $scope.addMarksGeneric($scope.activityThreeMarks, 10);
      }
      toaster.clear('*');
      toaster.pop({
        type: 'info',
        title: 'step 2',
        body: ' body of step two message',
        toasterId: 2
      });
      $scope.questionNumber = $scope.questionNumber + 1;
    } else {
      $scope.deductMarksGeneric($scope.activityThreeMarks, 5);
      toaster.pop({
        type: 'error',
        title: 'try again',
        body: 'please try again.',
        toasterId: 2
      });
    }
  } else {
    $scope.deductMarksGeneric($scope.activityThreeMarks, 5);
    toaster.pop({
      type: 'error',
      title: 'try again',
      body: ' Please continue according to the steps.',
      toasterId: 2
    });
  }
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Chinthani
  • 45
  • 1
  • 1
  • 7
  • Weird question: have you tried to use a `setTimeout(function(){ ... }, );`? Try it, with all the code after `var content = document.[...]`. Try with a big timeout (2-3 seconds), in case the browser just needs some time, or something. This is NOT a solution but just a test. – Ismael Miguel Nov 13 '19 at 11:38
  • Thank you so much it works. $timeout(function () { toaster.clear('*'); toaster.pop({type:'info',title:'step 2',body:'body of step 2.',toasterId:2}); $scope.questionNumber = $scope.questionNumber + 1; },1000); – Chinthani Nov 14 '19 at 05:59
  • That is actually pretty weird. I would expect it to do not work if the `toaster.clear('*');` is inside the timeout. – Ismael Miguel Nov 14 '19 at 09:28
  • hmm. yah I also don't understand how it worked there. – Chinthani Nov 19 '19 at 10:01

0 Answers0