0

我正在使用 redips 拖动类来拖放表格的表格单元格。如果目标单元格为空,我想添加一个条件以禁止丢弃。这意味着如果目标单元格不为空,我只需要“切换”。有什么帮助吗?

if (target_elements_length) {
                    // call myhandler_switched because clone_limit could call myhandler_clonedend1 or myhandler_clonedend2
                    REDIPS.drag.myhandler_switched();
                    // and myhandler_dropped
                    REDIPS.drag.myhandler_dropped(target_cell);
                    // if object is cloned, update climit1_X or climit2_X classname
                    if (cloned_flag === 1) {
                        clone_limit();
                    }
                }
                // otherwise element is dropped to the empty cells
                else {
                         //TODO cancel the event.
                }
4

1 回答 1

0

没关系......这就是解决方案。相应地修改drag.js:

 if (target_elements_length) {
                    obj.parentNode.removeChild(obj);
                    target_cell.appendChild(obj);
                    // call myhandler_switched because clone_limit could call myhandler_clonedend1 or myhandler_clonedend2
                    REDIPS.drag.myhandler_switched();
                    // and myhandler_dropped
                    REDIPS.drag.myhandler_dropped(target_cell);
                    // if object is cloned, update climit1_X or climit2_X classname
                    if (cloned_flag === 1) {
                        clone_limit();
                    }
                }
于 2013-08-27T10:27:26.967 回答