Reputation: 12896
I am using a gem to implement an event calendar on a website. It is the event_calendar gem.
I am getting the following error in chrome:
Uncaught TypeError: Object function Event() { [native code] } has no method 'observe'
It is generated in line 6 of event_calendar.js:
Event.observe(window, "load", function() {
Any ideas as of what is wrong?
I have a model called Event, so I suspect that it might somehow be interfering with the JS, but I'm not able to find that anywhere in my code.
What I find strange is that the event calendar works, with events and all. Could this be some issue with duplication? Again, I can't find any signs of this.
Upvotes: 1
Views: 431
Reputation: 1232
Sorry I might be a little late, I have just encountered the same issue and have managed to fix this error.
The event_calendar gem has implemented a couple of different implementation for different Javascript libraries. By default when you run
rails generate event_calendar
it does not generate the jquery's implementation which your rails app is most likely using.
The Event.observe pattern is a prototype.js function. Unless your rails app has included prototype.js first before the event_calendar gem, it will break.
To fix your problem, if you are using jquery as your default javascript library, you could run
1. rails generate event_calendar --use-jquery
2. then replace the app/assets/javascripts/event_calendar.js with the generated public/javascripts/event_calendar.js.
Hope it helps.
Upvotes: 2