Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined errors since update #33

Closed
classtechnologysolutions opened this issue Nov 19, 2014 · 7 comments
Closed

Undefined errors since update #33

classtechnologysolutions opened this issue Nov 19, 2014 · 7 comments

Comments

@classtechnologysolutions

I've updated fullcalendar-rails and generated an API key then turned on Calendar API.

I've added my API key to my code and now I'm getting this error:

$(document).ready(function() {
        $('#calendar').fullCalendar({
                googleCalendarApiKey: '<secret>',
                header: {
                    left: 'prev,next today',
                    center: 'title',
                    right: 'month,agendaDay',
                    timezone: 'Europe/London',
                },
                timeFormat: '',
        events: '<secret>@import.calendar.google.com',      
                timezone: 'Europe/London',
                loading: function(bool) {
                    $('#loading').toggle(bool);
                },
                eventClick: function(event) {
            if (event.url) {
                return false;
            }
            },
        });
    });

I'm getting these errors:

Uncaught ReferenceError: moment is not defined fullcalendar.js?body=1:13
Uncaught TypeError: Cannot read property 'applyAll' of undefined gcal.js?body=1:20
Uncaught TypeError: Cannot read property 'applyAll' of undefined gcal.js?body=1:20

fullcalendar.js
http://pastebin.com/zi6egy3H

gcal.js
http://pastebin.com/KNVY0tFW

@classtechnologysolutions
Copy link
Author

Also, to add, here is the top of my application.js file:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery.ui.all
//= require jquery_ujs
//= require ckeditor/init
//= require fullcalendar
//= require fullcalendar/gcal
//= require_tree .

@classtechnologysolutions
Copy link
Author

I didn't include momentjs!

@maxbeizer
Copy link

@classtechnologysolutions could you expand on what you did to resolve this please? I am seeing the moment is not defined error.

The gemspec lists momentjs-rails as a runtime dependency, so I should not need to add it to the gemfile. I have tried adding //= require moment to application.js and I still see the error.

I am using Rails 4.1.7 and Ruby 2.1.5. The fullcalendar version is 2.2.0.0

@gr8bit
Copy link
Collaborator

gr8bit commented Dec 3, 2014

For some strange-to-me-but-surely-very-good-reason you have to explicitly add

gem 'momentjs-rails'

to your Gemfile and

//= require moment

to your application.js manifest.

@maxbeizer
Copy link

@gr8bit thanks for your reply. I added momentjs-rails to my gemfile, bundled and added moment to my manifest. I restarted my server and I'm still seeing Uncaught ReferenceError: moment is not defined in my browser console.

For reference, my gemfile and manifest:

source 'https://rubygems.org'
ruby '2.1.5'

gem 'rails',                    '4.1.7'
gem 'mysql2',                   '~> 0.3.16'
gem 'thin',                     '~> 1.6.3'
gem 'whiskey_disk'
gem 'jquery-rails'
gem 'selectivizr-rails'
gem 'respond-rails'
gem 'devise'
gem 'bourbon'
gem 'neat'
gem 'sass-rails',               '~> 4.0.3'
gem 'uglifier',                 '>= 1.3.0'
gem 'modernizr-rails'
gem 'normalize-rails'
gem 'coffee-rails',             '~> 4.0.0'
gem 'turbolinks'
gem 'jbuilder',                 '~> 2.0'
gem 'paperclip',                '~> 4.2'
gem 'aws-sdk',                  '~> 1.59.0'
gem 'stringex',                 '~> 2.5.2'
gem 'fullcalendar-rails',       '2.2.0.0'
gem 'momentjs-rails'
gem 'spring',                   group: :development

group :production do
  gem 'heroku_rails_deflate'
end

group :development do
  gem 'foreman'
  gem 'guard-bundler'
  gem 'guard-rspec'
  gem 'guard-spork'
  gem 'guard-livereload',       require: false
  gem 'rack-livereload'
  gem 'rb-fsevent',             require: false
end

group :development, :test do
  gem 'dotenv-rails'
  gem 'factory_girl_rails'
  gem 'pry-rails'
  gem 'pry-nav'
  gem 'awesome_print'
  gem 'quiet_assets'
  gem 'spring-commands-rspec',  '~> 1.0.2'
  gem 'rspec-rails'
end

group :test do
  gem 'spork-rails'
  gem 'database_cleaner'
  gem 'shoulda-matchers',       :require => false
  gem 'capybara-webkit'
  gem 'launchy'
  gem 'fuubar'
  gem 'simplecov'
end
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree ../../../vendor/assets/javascripts
//
//= require fullcalendar
//= require moment
//= require_tree .

@maxbeizer
Copy link

It helps to put the requires in this order:

//= require moment
//= require fullcalendar

@gr8bit
Copy link
Collaborator

gr8bit commented Dec 4, 2014

That should be noted in the readme. Done. Thank you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants