简体   繁体   English

Ext Js 向 html 元素添加事件

[英]Ext Js add event to html element

How can add onChange event to my html element which is rendered inside another component如何将 onChange 事件添加到我在另一个组件中呈现的 html 元素

  xtype: 'component',
                        html: {
                            html: '<input  type= "color" />'
                        },
                        itemId: 'colorPicker'
                    },

I want to add the following eventlistener to the input elelement:我想将以下事件侦听器添加到输入 elelement:

   theInput.addEventListener("input", function() {

   <<Do something with theColor value here>>

    }, false); 

In your case code is something like this:在你的情况下,代码是这样的:

html: '<input id=\'colorPickerBackground\' type=\'color\'></input>',
listeners: {
    afterrender: function(component) {
        var colorInput = component.getEl().down('#colorPickerBackground');
        colorInput.on('input', function() {
            console.log(colorInput.getValue());
        }); 
    }
}

Simple fiddle简单的小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM