Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
10966 Vistas

Hi Community,


There is a js file called list_view.js in  server/addons/web/static/src/js/views.
Inside of it, we have: 

ListView.List = Class.extend({

    init: function (group, opts) {     

        this.$current = $('<tbody>')

            .delegate('input[readonly=readonly]', 'click', function (e) {

                e.preventDefault();

            })

            .delegate('td.o_list_record_delete', 'click', function (e) {

                e.stopPropagation();

                var $row = $(e.target).closest('tr');

                $(self).trigger('deleted', [[self.row_id($row)]]);

                // IE Edge go crazy when we use confirm dialog and remove the focused element

                if(document.hasFocus && !document.hasFocus()) {

                    $('<input />').appendTo('body').focus().remove();

                }

            })

},

Can you tell me how can i inherit  the listView.List and  add extra code to the .delegate('td.o_list_record_delete', 'click', function (e) {..}  section ? 

Thank you.

Avatar
Descartar
Mejor respuesta

Hi Ibrahim, 

You can simply achieve this by extending the list view. First, take an instance of ListView and then you can extend the ListView.List and update the code. I'll paste the sample code below,


// taking the instance of ListView
var ListView = require('web.ListView');

// extending the ListView.List
ListView.List.include({
    init: function(group, opts){
          this._super(group, opts);
          // (add your extra code to delegate(... here.
    }
});


Thanks





Avatar
Descartar
Autor

Thank you for your reply.

I don't know what's the difference between self._super.apply(self, arguments); AND this._super(group, opts);

I wrote the same code but with the first _super and didn't work until i set the second _super.

Publicaciones relacionadas Respuestas Vistas Actividad
1
dic 22
4603
2
jul 17
4280
0
may 24
1772
5
sept 20
31657
1
nov 17
11533