2012-12-25 100 views

回答

4

點擊事件不直接對組件起作用。相反,他們在組件的元素上工作得很好。因此,對於你的情況,你可以使用它像這樣:

在控制器中的「控制」,

control : { 
    // Your carousel reference 
    "carousel" : { 
     initialize : function(carousel){ 
      carousel.element.on('tap', function(e, el){ 
       // Here you will get the target element 
       console.log(e.target, el); 
      }, this); 
     } 
    } 
} 

您可以使用委託這種方式,如果你想對某些類型的唯一元素的捕捉龍頭事件:

carousel.element.on('tap', function(e, el){ 
    // Here you will get the target element 
    console.log(e.target, el); 
}, this, { 
    delegate : 'div.my-element' 
}); 

希望得到這個幫助。

+0

非常感謝!這工作。 – Michael

+0

嗨,我用這個代碼爲我的應用程序,但我想得到哪個點擊click.I有4個水龍頭在我的旋轉木馬。我會爲每個水龍頭創建4個js頁面。如果用戶點擊第一個水龍頭js將打開。如何我做? – tarik