这是我正在尝试做的事情:
-单击图像时,unbind
单击事件(在该图像上)并显示弹出窗口。
- 只要显示弹出窗口,您就不能单击该图像。
- 一旦弹出窗口被解除,点击事件再次绑定在图像上。
所以这是我的代码(图像包含在li
标签中)。
$('li').click(clickOnImage());//Bind the click event with call to clickOnImage method
function clickOnImage(){
var id=$(this).attr("id");
console.log('you selected image with id name: '+id);
showWithAnimation();//Show the popup with animation
}//End function
function showWithAnimation(){
console.log('animation called');
$('#popup').show();
$("#popup").css({"top": "10%", "left": "30%"}).animate({top:(($(window).height()/2)-($('#popup').outerHeight()/2))-10}, 1000, 'easeOutBounce').show();
//As long as the popup is shown, Unbind the click event on images
$('li').unbind('click');
}//End function
function hidePopUp(){
$('#popup').hide();
$('li').bind('click',clickOnImage());//if popup is hidden, re-bind the click event and here is the issue!
}//End function
在 FireFox 上运行时,我在控制台中收到此错误:
Unexpected end of file while searching for selector. Ruleset ignored due to bad selector.
我认为问题在于该函数被递归调用。但我需要执行这种方法。请问我该如何解决。提前谢谢。