Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
11135 มุมมอง

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.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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





อวตาร
ละทิ้ง
ผู้เขียน

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 ตอบกลับ มุมมอง กิจกรรม
1
ธ.ค. 22
4775
2
ก.ค. 17
4490
0
พ.ค. 24
1993
5
ก.ย. 20
32106
error: Some modules could not be started แก้ไขแล้ว
1
พ.ย. 17
11726