我想箱子全景滑块作为一个jQuery插件,我有以下代码..jQuery插件:获取其他功能里面的“此”对象
$.fn.panorama = function(settings) {
var myPanorama = this;
..
this.mousedown(function(e){
//do stuff
$(this).css... //this all work
}
//Call mouseup on document in case user lets go of mouse outside draggable object
$(document).mouseup(function(){
$(myPanorama).easeDragging(); //works but probably not the way to do it
this.easeDragging(); //ideal but refers to wrong object
});
}
我的问题是我如何参考到$(document).mouseup调用中的“this”对象?
因为它认为“this”是文档本身,而不是附加到插件的对象。
现在我只是做一个变量,它的工作原理,但必须有更好的方法!
谢谢!
您也可以在这里使用'$ .proxy()',例如, '$ .proxy(function(){this.easeDragging();},this)':) – 2010-08-19 19:28:56
@Nick:一个非常有用的jQuery函数,我不知道,谢谢:-) – 2010-08-19 19:32:39
优秀的答案,我学到了一些东西新的每一天! – Totomobile 2010-08-19 20:51:01