Hi thank you for yout attention.
I have the next module
define(['./solicitudModelHelena'], function (SolicitudAdmision) {
create: function (model, template) {
return new Backbone.Form({
importe_exposicion: { type: 'Text', title: 'Exposición calculada', editorAttrs: { readonly: 'readonly' }, editorClass: 'cursorAuto' },
exposicion_mod: { type: 'Text', title: 'Exposición modificada', fieldClass: 'no-display', editorAttrs: { tabindex: '3'} },
check_modify_exp: { type: 'Checkbox', title: 'Modificar', editorAttrs: { tabindex: '2'} },
tip_operacion: { type: 'Radio', title: null, editorAttrs: { 'data-type': 'inline-radio' }, options: [
{ val: SolicitudAdmision.OPERACION_NORMAL, label: 'Admisión de un cliente' },
{ val: SolicitudAdmision.OPERACION_ESPORADICA, label: 'Operación esporádica' }
The render of the view use it
render: function () {
//render template of the view...
this.createModel();
this.form = SolicitudForm.create(this.model, this.templateForm);
this.$el.prepend(this.form.el);
this.form.render();
return this;
The templateForm is
<header><h2>Datos</h2></header>
<div data-fields="importe_exposicion"></div>
<div data-fields="check_modify_exp"></div>
<div data-fields="exposicion_mod"></div>
<header><h2>Datos </h2></header>
<div data-fields="tip_operacion"></div>
It works if I return in create of the form the result of render
define(['./solicitudModelHelena'], function (SolicitudAdmision) {
return {
create: function (model, template) {
return new Backbone.Form({
schema: {
....
},
model: model,
template: template
}).render();
}
}
});
And after get the form in the render method of the superview do the prepend, so the render is before appending the form el to his parent.
this.form = SolicitudForm.create(this.model, this.templateForm);
this.$el.prepend(this.form.el);
The result is what I want, but allways I try to append before render to avoid some problems.
Thanks