Does callback take precedence to view child element?

I have several connected props.

Firstly:

App.Views.TreeGrowthBase = App.Views.TreeGrowthBase.extend({
  events: {
    'submit form': 'submitForm',
...

and then in the same file:

submitForm: function(e) {
    e.preventDefault();

and elsewhere in the application:

App.Views.WineTreeGrowthBase = App.Views.TreeGrowthBase.extend({
  submitForm(event) {
    event.preventDefault();

My questions: In this last piece of code ... what is the syntax:

submitForm(event) {
    event.preventDefault();

Is this a method call? Method definition? Where are the colons?

Which one has priority? I believe that the definition of the child method submitFormtakes place ... if this is the definition of a method?

+4
source share
1 answer

Abbreviation of method definition

submitForm(event) {
    event.preventDefault();

This is a brief description of the method definition in ES6 (ECMAScript 2015).

It is equivalent

submitForm: function submitForm(event) {
    event.preventDefault();

( foo: function() {}). ( ). . function.

, (, IE).

, Backbone ( extend), . , :

submitForm: function(event) {
    // Using the Backbone '__super__'
    ThisClass.__super__.submitForm.apply(this, arguments);
    // Or the JavaScript preferred way
    ParentClass.prototype.submitForm.apply(this, arguments);
    event.preventDefault();
}

Backbone. . extend function.

. .


this.constructor.__super__, , , , . MyCurrentClass.__super__, .

+4

Source: https://habr.com/ru/post/1664220/


All Articles