如何在JQuery脚本中取消绑定JQZOOM? [英] How can I unbind JQZOOM in my JQuery Script?

查看:92
本文介绍了如何在JQuery脚本中取消绑定JQZOOM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此刻我有这个脚本,当更改缩略图时,它会更改图像.然后,我希望将JQZOOM添加到该新图像.但是,如果我将其放在Onclick事件中,则单击它的次数越多,它就会变得越来越慢...我想是因为它运行多个实例.

I have this script at the moment, which changes an image when a thumbnail has been changed. I then want JQZOOM to be added to that new image. However, if I put it inside the Onclick event, it gets slower and slower the more times you click on it... I guess because its running multiple instances.

反正有什么方法可以将JQZOOM与某个对象解除绑定,然后将其重新绑定至其他对象?

Is there anyway to unbind the JQZOOM from something then rebind it to something else?

此刻是我的jquery:

Here is my jquery at the moment:

var options = {
    zoomWidth: 400,
    zoomHeight: 325,
    xOffset: 25,
    yOffset: 0,
    position: "right",
    lens: true,
    zoomType: "reverse",
    imageOpacity: 0.5,
    showEffect: "fadein",
    hideEffect: "fadeout",
    fadeinSpeed: "medium",
    title: false
};

$('.jqzoom').jqzoom(options);

$('.single-zoom-image').click ( function () {

    $('#bigProductImage').attr("src", $(this).attr("zoom"));
    $('.jqzoom').attr("href", $(this).attr("extrazoom"));

});

在此先感谢您能帮助我.

Thanks in advance if anyone can help me.

干杯!

推荐答案

这可以按照以下步骤进行:

This can be done as follows:

修改其他鼠标功能所在的jqzoom1.0.1.js(在第90行附近)

Modify jqzoom1.0.1.js where the other mouse functions are (around line 90)

//Handle clicked thumbnails changing the zoomed image
$(this).bind('changeimage', function(){
   smallimage = new Smallimage( $("img", this) );
   largeimage = new Largeimage(a[0].href);
    smallimage.loadimage();
});

按如下所示调用缩放器:

Call the zoomer as follows:

$(document).ready(function(){
var options = {
zoomWidth: 300,
zoomHeight: 200,
xOffset: 30,
yOffset: 0,
position: 'right',
title: false,
showPreload: false
};

//Handle clicking on the thumbnails, swap the mainimage and recycle the zoomer
$('.seemore').bind('click', function(e) {
    e.preventDefault();
    $('.jssProductFullImage').attr('src', $(this).attr('href'));
    $('.zoomer').attr('href', $(this).attr('href') );
    //Recall the zoomer to update the page
    $('.zoomer').trigger('changeimage');

    });
$('.zoomer').jqzoom(options);

});

这篇关于如何在JQuery脚本中取消绑定JQZOOM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆