这是我的观点:
$(function() {
var ImageManipulation = Backbone.View.extend({
el: $('body'),
tagName: "img",
events: {
'mouseover img': 'fullsize',
'click img#current': 'shrink'
},
initialize: function() {
_.bindAll(this, 'render', 'fullsize', 'shrink');
//var message = this.fullsize;
//message.bind("test", this.fullsize);
},
render: function() {
},
fullsize: function() {
console.log("in fullsize function");
console.log(this.el);
$('.drop-shadow').click(function() {
console.log(this.id);
if (this.id != 'current') {
$('.individual').fadeIn();
$(this).css('position', 'absolute');
$(this).css('z-index', '999');
$(this).animate({
top: '10px',
height: '432px',
}, 500, function() {
this.id = "current";
console.log("animation complete");
return true;
});
};
});
},
shrink: function() {
$('.individual').fadeOut();
$('#current').animate({
height: '150px',
}, 500, function() {
this.id = "";
$(this).css('position', 'relative');
$(this).css('z-index', '1');
console.log("animation complete");
return true;
});
}
});
var startImages = new ImageManipulation();
});
我不明白的是如何更改el,使得“this”接管我在全尺寸中拥有的点击函数。我更希望删除click jQuery函数,并将mouseover函数作为另一个点击函数,但我似乎无法弄清如何将“this”分配给被单击的特定图像。希望我的问题表达清楚。
http://documentcloud.github.com/backbone/#View-extend
пјҢеҗҢж—¶el: 'body'
дёҚжҳҜ$('body')
гҖӮеңЁе…¶дёӯдёҖдёӘзӨәдҫӢдёӯпјҢе®ғеҸҜиғҪжңҹжңӣе®ғжҳҜдёҖдёӘеӯ—з¬ҰдёІиҖҢдёҚжҳҜдёҖдёӘеҜ№иұЎгҖӮ - Val