zoukankan      html  css  js  c++  java
  • (59) 解决在列表视图复制导致打开详细内容

    现象:
    在列表视图中,当你要复制一个内容,就触发click事件,就打开form视图了
    为了区分click mousedown mousemove muuseup 事件,从而放弃click事件
    用后面那几个事件组合来解决是要打开,还是复制内容事件

    改动代码如下:
    addonswebstaticsrcjsview_list.js

    var hasMove =false;
            this.$current = $('<tbody>')
                .delegate('input[readonly=readonly]', 'click', function (e) {
                    /*
                        Against all logic and sense, as of right now @readonly
                        apparently does nothing on checkbox and radio inputs, so
                        the trick of using @readonly to have, well, readonly
                        checkboxes (which still let clicks go through) does not
                        work out of the box. We *still* need to preventDefault()
                        on the event, otherwise the checkbox's state *will* toggle
                        on click
                     */
                    e.preventDefault();
                })
                .delegate('th.oe_list_record_selector', 'click', function (e) {
                    e.stopPropagation();
                    var selection = self.get_selection();
                    var checked = $(e.currentTarget).find('input').prop('checked');
                    $(self).trigger(
                            'selected', [selection.ids, selection.records, ! checked]);
                })
                .delegate('td.oe_list_record_delete button', 'click', function (e) {
                    e.stopPropagation();
                    var $row = $(e.target).closest('tr');
                    $(self).trigger('deleted', [[self.row_id($row)]]);
                })
                .delegate('td.oe_list_field_cell button', 'click', function (e) {
                    e.stopPropagation();
                    var $target = $(e.currentTarget),
                          field = $target.closest('td').data('field'),
                           $row = $target.closest('tr'),
                      record_id = self.row_id($row);
                   
                    if ($target.attr('disabled')) {
                        return;
                    }
                    $target.attr('disabled', 'disabled');

                    // note: $.data converts data to number if it's composed only
                    // of digits, nice when storing actual numbers, not nice when
                    // storing strings composed only of digits. Force the action
                    // name to be a string
                    $(self).trigger('action', [field.toString(), record_id, function (id) {
                        $target.removeAttr('disabled');
                        return self.reload_record(self.records.get(id));
                    }]);
                })
                .delegate('a', 'click', function (e) {
                    e.stopPropagation();
                })
               .delegate('tr', 'mousedown', function (e) {

                    if (e.button ==0){
                       hasMove=false;
                    }else {
                       hasMove=true;
                    }

                })

                .delegate('tr', 'mousemove', function (e) {

                    hasMove=true;
                })

                .delegate('tr', 'mouseup', function (e) {

                    if (hasMove || (e.srcElement.type && e.srcElement.type=='checkbox')){

                    }else{
                    var row_id = self.row_id(e.currentTarget);
                    if (row_id) {
                        e.stopPropagation();
                        if (!self.dataset.select_id(row_id)) {
                            throw new Error(_t("Could not find id in dataset"));
                        }
                        self.row_clicked(e);
                    }
                    }
                    hasMove =false;
                });

    ====================================
    上面是一种解决方案,但当ommousemove 事件,移动鼠标触发事件过多,导致客户端会死掉,最终用下面的方法
    得到较好的解决
    当鼠标移动时,有复制到内容,则不进入详细面,判断没有内容来决定:

    addonswebstaticsrcjsview_list.js

    .delegate('tr', 'click', function (e) {

                    var txt = window.getSelection?window.getSelection():document.selection.createRange().text;
                    if (txt!=''){
                      e.stopPropagation();

                    }else{

                        var row_id = self.row_id(e.currentTarget);
                        if (row_id) {
                            e.stopPropagation();
                            if (!self.dataset.select_id(row_id)) {
                                throw new Error(_t("Could not find id in dataset"));
                            }
                            self.row_clicked(e);
                        }
                    }


                });

  • 相关阅读:
    kafka学习-卡不卡的简单使用
    mongoDB-mongo compass使用学习-最像关系型数据库的非关系型文档型数据库
    postman使用-跑男常用功能
    jmeter数据驱动csv+批量导出数据到csv文件
    jmeter-数据库查询与调用-mysql
    arch linux mysql using
    Win10安装 oracle11g 出现INS-13001环境不满足最低要求解决方法
    oracle11g数据库安装
    安装PLSQLDeveloper
    oracle基本学习
  • 原文地址:https://www.cnblogs.com/toby2chen/p/8177267.html
Copyright © 2011-2022 走看看