首页 > jquery中delegate问题

jquery中delegate问题

请问大家一个我在delegate使用过程中遇到的问题:
用delegate动态绑定,用改成这样:

$(function() {
                $("#desktop").delegate(".AppContent", "resize", function() {
                    var _this = $(this);
                    var win = _this.parents(".AppWindow");
                    win.css({
                        "height": (_this.height() + 20) + "px",
                        "width": _this.width() + "px"
                    });
                });
                $("#desktop").delegate("AppTitleBar", "mousedown", function(e) {
                    var _this = $(this);
                    var win = _this.parents(".AppWindow");
                    appManager.setTop(win);
                    _this.css("cursor", "move"); //改变鼠标指针的形状 
                    var offset = _this.offset(); //DIV在页面的位置 
                    var x = e.pageX - offset.left; //获得鼠标指针离DIV元素左边界的距离 
                    var y = e.pageY - offset.top; //获得鼠标指针离DIV元素上边界的距离 
                    $(document).bind("mousemove", function(ev) { //绑定鼠标的移动事件,因为光标在DIV元素外面也要有效果,所以要用doucment的事件,而不用DIV元素的事件 
                        //_this.stop(); 
                        var _x = ev.pageX - x; //获得X轴方向移动的值 
                        var _y = ev.pageY - y; //获得Y轴方向移动的值 
                        win.css({
                            "left": _x + "px",
                            "top": _y + "px"
                        });
                    });
                    $(".AppWindow AppTitleBar").mouseup(function() {
                        _this.css("cursor", "default");
                        $(document).unbind("mousemove");
                    });
                    $(document).mouseup(function() {
                        _this.css("cursor", "default");
                        $(document).unbind("mousemove");
                    });
                });
            });

但是这样的话resize不生效,
jquery的resize被插件修改成可以监听元素的大小变化,不是原来的只能监听document的大小变化了
不知道是那里遇到问题,请大家指导一下,谢谢。


是在已有的父元素,譬$("body")


delegate的第二个参数写错了吧,直接是事件类型,没有on。

【热门文章】
【热门文章】