开发者

.bind() statement not working in jQuery Easy Confirmation plugin

Did anyone who used jQuery Easy Confirmation plugin run into this issue - the button upon which the confirm box is bound loses its original click event after the first click? I had to change the plugin code to this to make it work. The difference here is between .bind and .click. Can anyone explain why? Pls. let me know if my question is not clear. Thx!

开发者_如何转开发

Original plugin code:

     // Re-bind old events
            var rebindHandlers = function () {

                if (target._handlers != undefined) {
                    jQuery.each(target._handlers, function () {
                        //this is the difference
                        $target.bind(type, this);   
                    });
                }
            }

Changed (working) code:

    // Re-bind old events
            var rebindHandlers = function () {

                if (target._handlers != undefined) {
                    jQuery.each(target._handlers, function () {
                        //this is the difference
                        if(type == 'click')
                            $target.click(this);
                        else {
                            $target.bind(type, this);   
                        }
                    });
                }
            }


Try using some alerts to see what's happening...

// Re-bind old events 
var rebindHandlers = function () {
            if (target._handlers != undefined) {
                jQuery.each(target._handlers, function () {
                    if(type == 'click')
                        alert('$target.click(' + this + ');');
                        //$target.click(this);
                    else {
                        alert('$target.bind(' + type + ', ' + this + ');');
                        //$target.bind(type, this);   
                    }
                });
            }
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜