HubSpot / messenger

Growl-style alerts and messages for your app. #hubspot-open-source
http://github.hubspot.com/messenger/
MIT License
4.02k stars 406 forks source link

Theme on post method #102

Open fvfv opened 8 years ago

fvfv commented 8 years ago

I would like to reuse the Messenger object and include in the options a different theme depending on the message from the server.

In other words. I'm not able to pass theme option on the post method. I can only change the theme on Messenger.options = {theme:'air'}; But since its a global change, I am not able to reuse an already initialized Messenger object from the same page. I believe the way that I'm doing it will cause a memory leak:

Messenger.options = {theme:'air'}; Messenger().post ("test");

If this code is run many times while the page is not refreshed. Am I wrong in assuming that Messenger() creates a new instance every time is run?

urosgruber commented 8 years ago

Theme is Messenger property. So try

Messenger({theme:'air'}).post ("test");

leompeters commented 7 years ago

@urosgruber I tried what you said but still getting the same error. Do you have other options:

I am having a similar issue but for this.options.themes in the file https://github.com/HubSpot/messenger/blob/master/docs/welcome/javascripts/theme-sel.js#L25:

Uncaught TypeError: Cannot read property 'themes' of undefined

leompeters commented 7 years ago

Got it!!! My similar issue was gone with UnderscoreJS VERSION 1.4.3 and BackboneJS VERSION 0.9.10.