How can i insert an handler for an HTML object?
question is simple!
I have an object like this:
new Ext.Panel({
id: 'Panel',
fullscreen: true,
dockedItems: [
dock:...,
width: ...,
开发者_如何转开发 listeners: { el: /*TOUCHEVENTS*/ },
html: '<object id='objectID' data="blabla"/>'
]
});
How can i add an event (like tap or pinch) on the HTML object with id= ObjectID ???
Thanks in advance ;)
I suggest you to use event delegation to makes possibile what you request. Event delegation allow you to set tap listeners on a specific target on your panel inner HTML object. I write you an example that show you how to do that:
Ext.setup({
onReady: function() {
//Definition of a handler function
var myHandler = function(){
Ext.Msg.alert('What???','Did you Tap me?');
};
//Definition of a simple Panel
var p = new Ext.Panel({
fullscreen: true,
dockedItems: [{
xtype: 'panel',
dock: 'top',
height: '30',
html: '<div id="myObject">Tap me please</div>',
listeners: {
body: {
tap: myHandler,
delegate: '#myObject'
}
}
}]
});
}
});
If you run this code, you will see that, when you tap on the "Tap me Please!" div, your event will be fired.
Hope this helps.
Something like:
var p = new Ext.Panel({
id: 'Panel',
fullscreen: true,
dockedItems: [
html: '<object id='objectID' data="blabla"/>'
]
});
p.on('render', function() {
Ext.get("objectID").on('click', function() {
alert('imclicket');
});
});
精彩评论