Commit cd3868f5 authored by alexandre's avatar alexandre

Wip for regions refreshing on login/logout

parent 77139e26
......@@ -20,12 +20,19 @@ window.W = window.W || {};
var radio = this.getChannel();
this.model = new W.UserAuthModel();
this.listenTo(this.model, 'change', function() { radio.request('change', this.model); });
// this.listenTo(this.model, 'change', function() { radio.trigger('change', this.model); });
// this.listenTo(this.model, 'change', function() {
// var view = this.getView();
// // console.log(view);
// // view.destroy();
// // var baseView = new W.BaseView({model: this.model});
// // this.showView(baseView);
// });
var baseView = new W.BaseView({model: this.model});
this.showView(baseView);
baseView.model.fetch();
// hide modals when typing escape
$(document).on("keydown", function(event) {
if (event.keyCode == 27) {
......
......@@ -1702,13 +1702,10 @@ window.W = window.W || {};
W.ScoreDetailView = Marionette.View.extend({
template: '#score-template-vue',
attributes: function () {
console.log(this.model);
return {
id: 'score',
class: this.model.get('is_editable') ? "content" : "content read-only",
tabindex: '1'
};
attributes: {
id: 'score',
class: 'content',
tabindex: '1'
},
regions: {
......@@ -1903,6 +1900,8 @@ window.W = window.W || {};
onRender: function () {
document.title = this.model.get('title');
this.$el.toggleClass('read-only', !this.model.get('is_editable'));
var mainlineView = new W.TreeNode({ model: this.model.get('mainline') });
this.showChildView('mainline', mainlineView);
......@@ -2597,11 +2596,11 @@ window.W = window.W || {};
},
initialize: function() {
Backbone.Radio.channel('user').reply('change', (this.renderUserScores).bind(this));
// Backbone.Radio.channel('user').on('change', (this.renderUserScores).bind(this));
},
renderUserScores: function (model) {
if (model.get("username")) {
renderUserScores: function () {
// if (this.model.get("username")) {
var collection = new W.ScoreCollection([], {
state: {
pageSize: 5,
......@@ -2622,14 +2621,16 @@ window.W = window.W || {};
this.showChildView('user_scores', view);
}).bind(this)
});
} else {
this.getRegion('user_scores').reset();
}
// } else {
// this.getRegion('user_scores').reset();
// }
},
onRender: function () {
document.title = 'Notation W';
this.renderUserScores();
var collection = new W.ScoreCollection([], {
state: {
pageSize: 5,
......@@ -2749,6 +2750,21 @@ window.W = window.W || {};
'click .js-help': 'showHelp'
},
// modelEvents: {
// 'change': 'foobar'
// },
// initialize: function() {
// this.listenTo(this.model, 'change', this.foobar);
// },
foobar: function() {
_.each(this.getRegions(), function(element, index, list) {
var currentView = element.currentView;
if (currentView) { currentView.render(); }
});
},
showHelp: function(event) {
var anchor = $(event.currentTarget).data("href");
var view = this.getRegion('help').currentView;
......
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