Commit b4366a7c authored by alexandre's avatar alexandre

listview en backbone

parent 9d642eeb
......@@ -11,7 +11,10 @@ window.W = window.W || {};
var router = new W.ScoreRouter();
/** Starts the URL handling framework */
Backbone.history.start();
Backbone.history.start({
pushState: true,
root: '/playground/score/'
});
}
});
})();
......@@ -6,6 +6,13 @@ window.W = window.W || {};
(function(undefined) {
'use strict';
W.ScoreCollection = Backbone.Collection.extend({
url: '/api/scores/',
model: W.ScoreModel
});
W.LineCollection = Backbone.Collection.extend({
model: W.LineModel
});
......
......@@ -7,12 +7,19 @@ window.W = window.W || {};
'use strict';
W.ScoreController = {
editScore: function(id) {
var params = {}
if (id) {params.id = id}
var myBaseView = new W.BaseView(params);
scoreList: function() {
var scoreCollection = new W.ScoreCollection();
var myListView = new W.ListView({collection: scoreCollection});
myListView.collection.fetch();
},
scoreCreate: function() {
var myBaseView = new W.BaseView();
myBaseView.render();
},
scoreView: function(id) {
},
scoreEdit: function(id) {
var myBaseView = new W.BaseView({id: id});
myBaseView.render();
}
};
......
......@@ -10,7 +10,10 @@ window.W = window.W || {};
controller: W.ScoreController,
appRoutes: {
'(:id)': 'editScore',
'': 'scoreList',
'create/': 'scoreCreate',
'(:id)/edit/': 'scoreEdit',
'(:id)/view/': 'scoreView',
},
});
})();
......@@ -547,4 +547,22 @@ window.W = window.W || {};
});
}
});
W.ListItemView = Backbone.Marionette.View.extend({
tagName: 'li',
template: '#list-item-template'
});
W.ListView = Backbone.Marionette.CollectionView.extend({
el: "body",
tagName: 'ol',
collection: W.ScoreCollection,
childView: W.ListItemView,
initialize: function(options) {
this.listenTo(this.collection, 'sync', this.render);
},
});
})();
......@@ -11,6 +11,14 @@
<link rel="stylesheet" href="http://meyerweb.com/eric/tools/css/reset/reset.css">
<link rel="stylesheet" href="{% static 'playground/css/styles.css' %}">
<script id="list-item-template" type="text/template">
<a href="<%= id %>/edit/"><%= title %></a>
</script>
<script id="score-edit-template" type="text/template">
ici le template pour lire les partitions
</script>
<script id="score-template" type="text/template">
<header>
<h1 contenteditable="true" id="title"><%- title %></h1>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment