ExtJs HTML component event instance

I created my own HTML component in extJS by specifying the value of the html panel. I cannot bind event handlers to an element (or they somehow do not fire). However, I can do other things on the component, for example, hide, add, etc.

Ext.select('#toFieldDiv').on('click',function() {
    alert("something");
});  //Doesn't Work

Ext.select('#toFieldDiv').hide('slow');  //Works

Any idea?

Here is my component definition:

{
    xtype: 'panel',
    x: 70,
    y: 0,
    html: "<div id=\"toFieldDiv\" class=\"to-field\"> </div>"
}

I even tried the same with jQuery. Hide again works, but not a click.

+5
source share
4 answers

I finally managed to solve the problem. The problem is not in this part of the code (as I expected). The event should and should work because it is just a normal click event for a div element.

, div , TextField div.

+1

, Sencha. .

 Ext.create('Ext.panel.Panel', {
    title: 'Hello',
    width: 200,
    html: '<p>World!</p>',
    listeners: {render: function(c){c.el.on('click', function() { alert('onclick');});}},
    renderTo: Ext.getBody()
});
+6

ExtJS 4?

"Ext.get" "Ext.select"?

ExtJS 4, . 4 "el" .

+1

Extjs 3.3.1 Ext.getCmp() .

Ext.select() CompositeElementLite/CompositeElement, Observable. on().

Ext.getCmp() Ext.Component, .

+1

All Articles