Skip to Content
Menu
This question has been flagged
1 Atsakyti
11138 Rodiniai

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.

Portretas
Atmesti
Best Answer

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





Portretas
Atmesti
Autorius

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.

Related Posts Replies Rodiniai Veikla
1
gruod. 22
4779
2
liep. 17
4491
0
geg. 24
2000
5
rugs. 20
32107
1
lapkr. 17
11727