mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
Reorder forms organisation add a way to custom view & add callback once error is rendered
This commit is contained in:
53
www/scripts/common/forms/views/input.js
Normal file
53
www/scripts/common/forms/views/input.js
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
define([
|
||||
"jquery",
|
||||
"underscore",
|
||||
"backbone",
|
||||
"common/forms/views/error",
|
||||
"common/multiviews"
|
||||
], function($, _, Backbone, ErrorView, MultiViews) {
|
||||
var InputView = Backbone.View.extend(_.extend({}, MultiViews, {
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
|
||||
if (! "name" in options) {
|
||||
throw "Missing name attribute in input view";
|
||||
}
|
||||
|
||||
if (! "errorTemplate" in options) {
|
||||
throw "Missing errorTemplate attribute in input view";
|
||||
}
|
||||
|
||||
this.name = options.name;
|
||||
|
||||
this.errorView = new ErrorView({
|
||||
name: this.name,
|
||||
errorTemplate: options.errorTemplate,
|
||||
onRenderError: options.onRenderError || null
|
||||
});
|
||||
},
|
||||
render: function () {
|
||||
this._assignView({".error-view" : this.errorView});
|
||||
},
|
||||
showErrors: function (errors) {
|
||||
this.render();
|
||||
|
||||
this.errorView.renderErrors(errors);
|
||||
|
||||
return this;
|
||||
},
|
||||
resetErrors: function () {
|
||||
this.errorView.reset();
|
||||
}
|
||||
}));
|
||||
|
||||
return InputView;
|
||||
});
|
Reference in New Issue
Block a user