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

TypeError: Object [object Object] has no method 'messenger' #65

Closed dgilfoy closed 10 years ago

dgilfoy commented 10 years ago

Trying to have multiple messenger containers on a single page (one standard, attached to body, the other contained in a wrapper div). However, I'm having some issues getting it to work as outlined in the Docs.

When I try to set an instance such as:

$('.messenger-wrapper').messenger(); 

I get the error

TypeError: Object [object Object] has no method 'messenger'

Not quite sure what I'm doing wrong. I'm loading jQuery first, then messenger and then the js file that contains my initialization. There are a few other libraries being called in between those files, but not getting any conflict errors.

I don't see the .messenger method anywhere in the jQuery object either (Chrome Developer tools).

Thanks in advance, it works wonderfully with once instance, but getting that second one is proving to be a bit tougher.

zackbloom commented 10 years ago

The messenger function gets added here: https://github.com/HubSpot/messenger/blob/master/src/coffee/messenger.coffee#L719 on the jQuery object available globally when you bring the file in: https://github.com/HubSpot/messenger/blob/master/src/coffee/messenger.coffee#L1

Is there any chance you're bringing in two copies of jQuery?

dgilfoy commented 10 years ago

Thanks for the quick response, zackbloom,

Not that I can tell. Unfortunately I'm having to use Drupal (and using the jQuery update module - so 1.8.2), but also using the 'jQuery Once' plugin (some module or another is using it) and the jQuery Foundation tooltips library (Foundation 3...) and also jQuery UI.

I double checked my resources tab, and my network tab in dev tools, and not seeing anything on that end. I'll keep trying stuff and keep you posted if I notice anything though.

zackbloom commented 10 years ago

If you want to log jQuery when it's added, and again when you're trying to use it, maybe that will help elucidate what's going on?

dgilfoy commented 10 years ago

Thanks zack, that led me to figure out there was some scope issues, seems to be working just fine now, thanks again for such a great library.