如何在drop之后调用函数-jquery sortable

时间:2016-07-08 17:38:21

标签: javascript jquery jquery-ui

我正在使用jquery可排序库。我的列表是可排序的(因为我可以拖放列表中的项目,就像我希望能够做到的那样)。但是在项目被删除后我似乎无法触发一个函数。

此外,.sortable()工作正常,但是当我尝试使用.disableSelection();

时出现错误

以下是示例代码:

o.onload = function () {
        data = _customization.data;
        for (id in data) {
            li = o.document.createElement("li");
            a = o.document.createElement("a");
            a.className = "module-customization";
            for (id2 in data[id]) {
                if (id2.indexOf("look") > -1) {
                    var temp = data[id][id2];
                    temp = temp.replace(_customization.pageOrigin, "");
                    temp = temp.replace(/([A-Z])/g, ' $1').trim()
                    a.innerHTML = temp;
                    if (a.getAttribute("Visible") != null) {
                        if (a.getAttribute("Visible") == "True") {
                            a.innerHTML = "<strong style=\"color:white\">" +a.innerHTML + "</strong><strong class=\"pull-right\" style=\"color:#d9534f;\" onClick=\"swapVisible(this)\">Hide</strong>";
                        }
                        else {
                            a.innerHTML = "<strong style=\"color:grey\">" + a.innerHTML + "</strong><strong class=\"pull-right\" style=\"color:#5cb85c;\" onClick=\"swapVisible(this)\">Show</strong>";
                            a.childNodes[0].style.setProperty("text-decoration", "line-through");
                        }
                    }
                } else if (id2.indexOf("Order") > -1) {
                    a.setAttribute("Order", data[id][id2]);
                }
                else if (id2.indexOf("Visible") > -1) {
                    a.setAttribute("Visible", data[id][id2]);
                }
                else {
                    a.setAttribute("rowID", data[id][id2]);
                }
            }
            a.Tag = data[id];
            a.id = id;
            li.appendChild(a);
            $(o.document.getElementById(_customization.pageSide)).sortable({
                receive: function (event, ui) {
                    alert("here");
                }
            });
            $(o.document.getElementById(_customization.pageSide)).disableSelection();

            o.document.getElementById(_customization.pageSide).appendChild(li);
        }
    }

对于一些上下文,“o”是一个已打开的窗口。我正在基于数组动态创建li元素 - 数据。所有这一切都很好,我只是觉得我会把它全部包括在内。

就像我说的那样,.sortable()显然是有效的,因为我可以拖放项目,但.disableSelection()给了我:

$(...)。disableSelection不是函数

为什么我不能让这个功能触发警报(“这里”)的任何想法?

谢谢!

1 个答案:

答案 0 :(得分:0)

过时的jquery ui库。问题解决了。