Search code examples
jquerytwitter-bootstrap-3pnotify

Pnotify change text after open


I want to use pnotify like status bar. I'm saving some records to database and i want to show that in pnotify like this.

"Saving 28 / 209"

But i didn't see any example to change pnotify content after it's open.

Here my javascript. This works but open a lots of notify.

var sayac = 0;
var i = setInterval(function () {
    var veriler = { 
        NotPuan: nesneler[sayac].value, 
        OgrenciID: nesneler[sayac].alt, 
        PayID: nesneler[sayac].name 
    };
    var listele = $.post("NotGiris/NotKaydet", veriler);

    $.pnotify({ 
        title: 'DURUM', 
        text: 'Kaydediliyor' + sayac + ' / ' + nesneler.length, 
        type: 'success', 
        delay: 1000 
    });

    console.log(Date());
    sayac++;
    if (sayac === nesneler.length) {
        clearInterval(i);
        window.location.replace('/Ders/Detay?Uyari=1');
    }
}, 200);

Solution

  • I think what you are looking for is the update function on the pnotify instance.

    var notice = new PNotify({
      title: 'Regular Notice',
      text: 'Check me out! I\'m a notice.'
    });
    $("#update").on('click', function() {
      notice.update({
        title: 'Updated title!'
      })
    });
    

    ... i.e., simply save the instance you are creating and then call .update(options) on it.

    See it in action on Plunkr.