そのため、ページ上の各 .featured-image が使用する再利用可能な関数を作成しようとしています。バックボーンイベントを使用せず、コメントアウトされたコードを書くだけで機能します。コメント付きのコードを模倣するイベント imageOver および imageOut を取得するにはどうすればよいですか??
app.newsroomPageElementView = Backbone.View.extend({
events: {
'mouseenter .featured-image': 'imageOver',
'mouseleave .featured-image': 'imageOut'
},
initialize: function () {
$(".featured-image").each(function(index, element){
var tl = new TimelineLite({paused:true});
tl.to(element, 0.2, {opacity:.9, scale:.9})
.to(element, 0.2, {backgroundColor:"#004", color:"orange"}, "-=0.1")
element.animation = tl;
})
// This part works if i don't use imageOver and imageOut
// $("li").hover(over, out);
// function over(){
// this.animation.play();
// }
// function out(){
// this.animation.reverse();
// }
},
imageOver: function (e) {
// What goes here?
},
imageOut: function (e) {
// What goes here?
}
});