コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
11139 ビュー

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.

関連投稿 返信 ビュー 活動
1
12月 22
4781
2
7月 17
4494
0
5月 24
2000
5
9月 20
32109
1
11月 17
11729