DeLe
DeLe

Reputation: 2480

Listen change on Filefield in extjs

I want listen when file has been change like. But It not working

{
            xtype: 'filefield',
            id: 'form-file',
            fieldLabel: 'Photo',
            name: 'photo-path',
            buttonText: '',
            buttonConfig: {
                iconCls: 'upload-icon'
            },
            listeners: {
                  'change': function(this, value){
                        alert('change');
                  }
            }
}

Upvotes: 0

Views: 6183

Answers (2)

DeLe
DeLe

Reputation: 2480

I found solution: function change must be:

change: function(f,new_val) { alert(new_val); }

Upvotes: 1

user2292083
user2292083

Reputation:

You can't do it with filefield of Extjs

I have the solution.

Example: http://jsfiddle.net/e3M3e/e8V7g/

var itemFile = null;
Ext.create('Ext.panel.Panel', {
    title: 'Hello',
    width: 400,
    html: "<input id='inputFile' type='file' name='uploaded'/>",
    renderTo: Ext.getBody(),
    listeners: {
        afterrender: function() {
            itemFile = document.getElementById("inputFile");            
            itemFile.addEventListener('change', EventChange, false);
        }
}
});

function EventChange(e){    
    var files = itemFile.files;
    console.log(files);
}

Upvotes: 1

Related Questions