Notifications - dynamically changing message

I’m following the notification component docs and creating the notification in the app.js globally. Before open(), I set the text via notification.params.text = “message”; When I open, the default text is in the notification. If I set the text and then issue console.log(notification.params), my new text is in the object.

Why is the new text not being rendered?

Ideally I would like to set one global notification and reuse it from any page.

did you try destroy the notification after closed?

app.notification.destroy(el)- destroy Notification instance

  • el - HTMLElement or string (with CSS Selector) or object. Notification element or Notification instance to destroy.


Thanks for the reply but I’m confused on why that’s an issue. Let me be more explicit.

var notificationWithButton = app.notification.create({
  icon: '<i class="icon demo-icon">7</i>',
  title: 'Framework7',
  subtitle: 'Notification with close button',
  text: 'Click (x) button to close me',
  closeButton: true,

notification.params.text = 'Some new text';;

The notification shows ‘Click (x) button to close me’

If the property is really read only, the documentation should say that.

bcs its created already, you need to destroy it and create a new instance of it. Maybe @nolimits4web has a better solution.

notificationWithButton.$el.find('.notification-text').text('Some new text');;
1 Like