0

I'm running Sinatra with Backbone.js. I'm trying to split up my models, views, etc so they aren't all lumped into a single JS file. Right now I have the following.

index.html

<html>

  <head>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
    <script src="scripts/underscore-min.js"></script>
    <script src="scripts/jquery-1.5.min.js"></script>
    <script src="scripts/backbone-min.js"></script>
    <script src="scripts/models.js"></script>

  ...

models.js

Models = {

  var Event = Backbone.Model.extend({

  });


  var Events = Backbone.Collection.extend({
    url: '/events',
    model: Event
  });

};

So models.js expects that Backbone.js has been loaded, which it should have been based on index.html, however, I'm getting a JavaScript error in models.js where I reference Backbone.Model.

Any ideas on what I'm missing here?

1 Answer 1

1

That isn't valid javascript. Something like this is more likely to work :

Models = {}

Models.Event = Backbone.Model.extend({

});


Models.Events = Backbone.Collection.extend({
  url: '/events',
  model: Event
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.