Je suis la mise en place est assez simple application avec la colonne vertébrale, et j'obtiens une erreur.
Uncaught TypeError: undefined is not a function example_app.js:7
ExampleApp.initialize example_app.js:7
(anonymous function)
C'est l'endroit où l'erreur s'affiche dans l'Inspecteur de Chrome (fichier init - example_app.js):
var ExampleApp = {
Models: {},
Collections: {},
Views: {},
Routers: {},
initialize: function() {
var tasks = new ExampleApp.Collections.Tasks(data.tasks);
new ExampleApp.Routers.Tasks({ tasks: tasks });
Backbone.history.start();
}
};
Voici mes tâches de l'index.haml fichier
- content_for :javascript do
- javascript_tag do
ExampleApp.initialize({ tasks: #{raw @tasks.to_json} });
= yield :javascript
modèles / task.js
var Task = Backbone.Model.extend({});
collections / tasks.js
var Tasks = Backbone.Collection.extend({
model: Task,
url: '/tasks'
});
les routeurs / tasks.js
ExampleApp.Routers.Tasks = Backbone.Router.extend({
routes: {
"": "index"
},
index: function() {
alert('test');
// var view = new ExampleApp.Views.TaskIndex({ collection: ExampleApp.tasks });
// $('body').html(view.render().$el);
}
});
Et voici la preuve que je vais appeler tous les fichiers (je pense):
<script src="/assets/jquery.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery-ui.js?body=1" type="text/javascript"></script>
<script src="/assets/underscore.js?body=1" type="text/javascript"></script>
<script src="/assets/backbone.js?body=1" type="text/javascript"></script>
<script src="/assets/backbone-support/support.js?body=1" type="text/javascript"></script>
<script src="/assets/backbone-support/composite_view.js?body=1" type="text/javascript"></script>
<script src="/assets/backbone-support/swapping_router.js?body=1" type="text/javascript"></script>
<script src="/assets/backbone-support.js?body=1" type="text/javascript"></script>
<script src="/assets/example_app.js?body=1" type="text/javascript"></script>
<script src="/assets/easing.js?body=1" type="text/javascript"></script>
<script src="/assets/modernizr.js?body=1" type="text/javascript"></script>
<script src="/assets/models/task.js?body=1" type="text/javascript"></script>
<script src="/assets/collections/tasks.js?body=1" type="text/javascript"></script>
<script src="/assets/views/task_view.js?body=1" type="text/javascript"></script>
<script src="/assets/views/tasks.js?body=1" type="text/javascript"></script>
<script src="/assets/views/tasks_index.js?body=1" type="text/javascript"></script>
<script src="/assets/routers/tasks.js?body=1" type="text/javascript"></script>
<script src="/assets/tasks/index.js?body=1" type="text/javascript"></script>
<script src="/assets/tasks/task.js?body=1" type="text/javascript"></script>
<script src="/assets/application.js?body=1" type="text/javascript"></script>
Toutes les idées seront grands. Merci!