user1584751
user1584751

Reputation:

Upgraded from jQuery 1.5 to 1.10.2 and code is not working

I have upgrade to jQuery 1.10.2 and jQuery UI 1.10.4 from jQuery 1.5.0 and jQuery UI 1.8.9, and the code below the code below has stop working properly. I changed the click function from 'live' to 'on' but it is still not working properly.

$('#tf_zoom').on('click', function(){
    if($tf_bg_img.is(':animated'))
        return false;

    var $this = $(this);
    if($this.hasClass('tf_zoom')){
        resize($tf_bg_img);
        $this.addClass('tf_fullscreen')
             .removeClass('tf_zoom');
    }else{
        var dim = getImageDim($tf_bg_img);
        $tf_bg_img.animate({
            width   :  dim.width,
            height  :  dim.height,
            top     :  dim.top,
            left    :  dim.left
        },350);
        $this.addClass('tf_zoom')
             .removeClass('tf_fullscreen');
    }

}

);

Upvotes: 1

Views: 138

Answers (1)

.on()

$(document).on('click','#tf_zoom', function(){
  //code here
});

Read Event Delegation

Syntax

$( elements ).on( events, selector, data, handler );

Best usage

$('parentElementPresesntAtDOMready').on('click','#tf_zoom',function(){
   // code here
});

Upvotes: 4

Related Questions