LoginSignup
0
0

More than 5 years have passed since last update.

Component 内の HTML Dom 要素にタップイベントを設定する

Posted at

HTML要素それぞれにonClickなどの実装をすることはせず、 上位の Component のイベントから delegate してもらう。
element オブジェクトのイベントのリスナーを登録、delegate オプションに、イベントの発生を拾いたい対象のリファレンスを記述する。

例:

controller/Maincoffee
# create instance
Ezuko.myView = new Ext.Container
  layout: 'card'
  items: [
    xtype:'panel'
    id: 'mypanel'
    html:'<div class="hoge"><img src="tapme.png" id="tappable"/></div>'
  ]
# add tap event listener on the img tag
Ext.getCmp('mypanel').element.on
  tap: (e)->
    alert 'tapped!'
  delegate: '#tappable'

# show view
MyApp.Viewport.push MyApp.myView
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0