Permalink
Browse files

finished edit form

  • Loading branch information...
wachterjohannes committed Feb 12, 2016
1 parent dba31e2 commit 737dc1f542467caa9ada59b4232bae8a85d06fe9
Showing with 30 additions and 4 deletions.
  1. +23 −4 Resources/public/js/components/news/form/main.js
  2. +7 −0 Resources/public/js/main.js
@@ -1,4 +1,4 @@
define(['text!./form.html'], function(form) {
define(['underscore', 'jquery', 'text!./form.html'], function(_, $, form) {

return {

@@ -42,7 +42,10 @@ define(['text!./form.html'], function(form) {
render: function() {
this.$el.html(this.templates.form({translations: this.translations}));

this.sandbox.form.create('#news-form');
this.form = this.sandbox.form.create('#news-form');
this.form.initialized.then(function() {
this.sandbox.form.setData('#news-form', this.data || {});
}.bind(this));
},

bindDomEvents: function() {
@@ -60,9 +63,10 @@ define(['text!./form.html'], function(form) {
return;
}

var data = this.sandbox.form.getData('#news-form');
var data = this.sandbox.form.getData('#news-form'),
url = this.templates.url({id: this.options.id});

this.sandbox.util.save(this.templates.url({id:null}), 'POST', data).then(function(response) {
this.sandbox.util.save(url, !this.options.id ? 'POST' : 'PUT', data).then(function(response) {
this.afterSave(response, action);
}.bind(this));
},
@@ -77,6 +81,21 @@ define(['text!./form.html'], function(form) {
} else if (!this.options.id) {
this.sandbox.emit('sulu.router.navigate', 'example/news/edit:' + response.id);
}
},

loadComponentData: function() {
var promise = $.Deferred();

if (!this.options.id) {
promise.resolve();

return promise;
}
this.sandbox.util.load(_.template(this.defaults.templates.url, {id: this.options.id})).done(function(data) {
promise.resolve(data);
});

return promise;
}
};
});
@@ -30,6 +30,13 @@ define(function() {
return '<div data-aura-component="news/form@examplenews"/>';
}
});

app.sandbox.mvc.routes.push({
route: 'example/news/edit::id',
callback: function(id) {
return '<div data-aura-component="news/form@examplenews" data-aura-id="' + id + '"/>';
}
});
}
};
});

0 comments on commit 737dc1f

Please sign in to comment.