Commit 3704d817 authored by alexandre's avatar alexandre

Using behavior for modals

parent b00b3424
......@@ -2480,10 +2480,10 @@ window.W = window.W || {};
});
W.BaseModalView = Marionette.View.extend({
attributes : {
class: 'page__modal modal',
},
W.ModalBehavior = Marionette.Behavior.extend({
// attributes : {
// class: 'page__modal modal',
// },
ui: {
'close': '.btn-close',
......@@ -2499,35 +2499,14 @@ window.W = window.W || {};
});
W.LoginView = W.BaseModalView.extend({
W.LoginView = Marionette.View.extend({
template: '#login-template',
onSubmit: function (foo, event) {
event.preventDefault();
var model = this.model;
var that = this;
var form = this.$el.find("form");
$.ajax({
type: "POST",
url: form.attr('action'),
data: form.serialize(),
success: function(data, textStatus, jqXHR) {
model.fetch();
that.trigger('hide:modal');
},
error: function(xhr, ajaxOptions, thrownError){
alert('login failed - please try again');
},
});
}
});
attributes : {
class: 'page__modal modal',
},
W.LoginView = W.BaseModalView.extend({
template: '#login-template',
behaviors: [W.ModalBehavior],
onSubmit: function (foo, event) {
event.preventDefault();
......@@ -2553,9 +2532,15 @@ window.W = window.W || {};
});
W.LogoutView = W.BaseModalView.extend({
W.LogoutView = Marionette.View.extend({
template: '#logout-template',
attributes : {
class: 'page__modal modal',
},
behaviors: [W.ModalBehavior],
onSubmit: function (foo, event) {
event.preventDefault();
......@@ -2579,9 +2564,15 @@ window.W = window.W || {};
});
W.RegisterView = W.BaseModalView.extend({
W.RegisterView = Marionette.View.extend({
template: '#register-template',
attributes : {
class: 'page__modal modal',
},
behaviors: [W.ModalBehavior],
templateContext: {
errors: undefined
},
......
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