我正在使用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.
}
答案 0 :(得分: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();
}
}