Good time of day. The problem is that you have to sit at work on weekends. I create the Marionette.LayoutView view in the template of which there is a form with a submit.
var FormModel = require("А"), ConfirmCodeView = require("..."), Template = require("А"), require("user/behaviors/behaviors"); var globalChannel = Backbone.Wreqr.radio.channel("global"), ... FormView; FormView = Marionette.LayoutView.extend({ className: "confirm-personal-data-view", getTemplate: function () { return Template; }, behaviors: { KeyboardScroll: { scrollEl: "form .content" }, RequiredField: {}, ProfileName: {}, ProfileValidation: {} }, ui: { form: "form" }, initialize: function (options) { this.model = new FormModel({...}); }, onRoute: function (step, confirmMethod, requestId) { if (confirmMethod && requestId) { this.addRegions({ phoneConfirm: "#region-phone-confirm" }); this.getRegion("phoneConfirm").show(new ConfirmCodeView({ ... })); } }, modelEvents: { ... }, events: { ... }, submitForm: function () { console.log("dataSubmit"); ... } }); return FormView;
Across the region, I display a child view of the ConfirmCodeView — Marionette.ItemView. In which template there is also a form with
var i18n = require("i18n"), templateHelpers = require("app/template-helpers"), FormModel = require("Б"), template = require("Б"); require("user/behaviors/behaviors"); var modalChannel = Backbone.Wreqr.radio.channel("modal"), FormView; FormView = Marionette.ItemView.extend({ className: "confirm-personal-phone-view", template: template, behaviors: { KeyboardScroll: { scrollEl: "form .content" }, RequiredField: {}, ProfileValidation: {} }, ui: { form: "form[name=verify-code]" }, initialize: function (options) { this.model = new FormModel({ ... }); }, events: { ... }, submitForm: function () { console.log("codeSubmit"); } }); return FormView;
The problem is that clicking Input[type=submit]
or this.ui.form.submit()
from the child ConfirmCodeView - Marionette.ItemView leads to submitForm ONLY in the parent LayoutView.
The option of directly calling the function this.submitForm()
when clicking on a button is not appropriate, since in bihaviors the SUBMIT event from the View is caught and validation, focus and scrolling of empty fields are triggered, and if all the rules are executed, submitForm()
.
Can someone tell me what this can be connected with? Event handling and code behaviors did not lay out, because I think that the problem is the lack of some theoretical knowledge.