Purpose of the code line this_super.aplly (this, arguments) ;?

0

I am developing a web application for a module in odoo, and it is necessary to create classes that can communicate with the models. I have been studying some code and it seems that in some functions it is necessary to use this line of code: this._super.apply(this, arguments); .

I know what the super is, but I do not understand what is the apply and why it is necessary to use the code to run smoothly. Can someone explain?

This is my entire code:

  odoo.define('tickets.JsController', function (require) { // <== 
define here
 'use strict';
//import do widget
var Widget = require('web.Widget');
var Operations = require('tickets.JsModel').O;

//quando o dom estiver preparado então cria as classes e aloca
require('web.dom_ready');

  var Component = Widget.extend({
     template: 'tickets.app',
     events: {'click .ticket_about': function (ev) {ev.preventDefault(); console.log('Olá');},},
     xmlDependencies: ['/tickets/static/src/xml/Dashboard_Tickets_Web.xml'],
     init: function (values) { // synchronous
         Object.assign(this, values);
         this._super.apply(this, arguments);
         console.log(arguments);
         console.log('init');
     },
     willStart: function () { // asynchronous, pre-render
        var self=this;// usado pq o ponteiro this não é acessivel dentro da then function
        return this._super.apply(this, arguments)//Aplicar os argumentos a classe pai widget
        .then(function (dummy, user) {
            console.log(arguments);
            console.log('willStart');
            console.log(self.o.GetMessage());
        });
     },
     start: function () {}, // asynchronous, post-render - use super as well!
     });

        var $elem = $('.o_ticket_app');
        var OP= new Operations();
        var app = new Component({o: OP});
        app.appendTo($elem).then(function () {
            console.log('Running');
        });
     });
    
asked by anonymous 07.03.2018 / 11:56

0 answers