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

marionette Cannot read property 'radio' of undefined #214

Closed
workmaster2n opened this issue Jan 24, 2015 · 9 comments
Closed

marionette Cannot read property 'radio' of undefined #214

workmaster2n opened this issue Jan 24, 2015 · 9 comments

Comments

@workmaster2n
Copy link

Gemfile:

source 'https://rails-assets.org' do
  gem 'rails-assets-marionette'
end

application.js:

//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require openlayers-rails
//= require equalize.min
//= require jquery.mmenu.min.all
//= require private_pub
//= require lodash
//= require backbone
//= require marionette
//= require arsite_web
//= require scripts
//= require_tree ../templates
//= require_tree ./models
//= require_tree ./collections
//= require_tree ./views
//= require_tree ./routers
//= require resources

my_app.js.coffee

@App = do(Backbone, Marionette) ->
  Arc = new Marionette.Application
  Arc.on "initialize:after", ->
    new @Routers.MyRouter()
    if Backbone.history
      Backbone.history.start(pushState: true)
  Arc

console.log @App

Output:
Uncaught TypeError: Cannot read property 'radio' of undefined in Backbone.Marionette

If I download the marionette.js file separately and place it in vendor/assets/javascript, I do not have any issue with the code.

@sheerun
Copy link
Contributor

sheerun commented Jan 24, 2015

What is the stack trace?

@workmaster2n
Copy link
Author

@sheerun:

Uncaught TypeError: Cannot read property 'radio' of undefinedbackbone.marionette-4ff9c0af35778e5d75d925c2ec20a32f.js?body=1:2681 
_.extend._initChannelbackbone.marionette-4ff9c0af35778e5d75d925c2ec20a32f.js?body=1:2548
Marionette.Applicationapp-2f9bd32802efa72485192d741e710830.js?body=1:4 
(anonymous function)app-2f9bd32802efa72485192d741e710830.js?body=1:15 
(anonymous function)app-2f9bd32802efa72485192d741e710830.js?body=1:19 
(anonymous function)

The line in question is:
this.channel = _.result(this, 'channel') || Backbone.Wreqr.radio.channel(this.channelName);

Line number 2681 in backbone.marionette.js.

@sheerun
Copy link
Contributor

sheerun commented Jan 29, 2015

I have no idea why it happens. Any guesses? What Rails Assets does wrong?

@workmaster2n
Copy link
Author

I noticed that backbone.wreqr is a separate file, so perhaps it is getting included in the wrong place?

@workmaster2n
Copy link
Author

Here's a project showing the issue: https://github.com/workmaster2n/marionette_bower_issue

@sheerun
Copy link
Contributor

sheerun commented Feb 12, 2015

This project doesn't use rails-assets at all. Did you forget to push something?

@workmaster2n
Copy link
Author

I must have missed a commit. Updated the project.

@sheerun
Copy link
Contributor

sheerun commented Feb 12, 2015

Rails Assets doesn't automatically require dependencies. It only installs them automatically.

You need to manually include all marionette dependencies like so:

//= require underscore
//= require backbone
//= require backbone.babysitter
//= require backbone.wreqr
//= require marionette
//= require backbone/app

@sheerun sheerun closed this as completed Feb 12, 2015
@workmaster2n
Copy link
Author

Awesome! Thanks for finding that. I assumed Bower pulled in a different file from Marionette.

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

No branches or pull requests

2 participants