1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    57
    Vote Rating
    0
    azbok is on a distinguished road

      0  

    Default [2.2][DUP] Bug + Fix in Examples form file-upload

    [2.2][DUP] Bug + Fix in Examples form file-upload


    I was using
    http://extjs.com/deploy/dev/examples...le-upload.html
    as an example and I randomly found a bug in
    http://extjs.com/deploy/dev/examples...UploadField.js

    If you select a file, hit reset, then select that same file, it doesn't appear in the form field. After a bit of searching around, I realize the underlying "input type=file" form element wasn't being reset. Since it wasn't reset, when you pick the same file again, the 'onChange' event wasn't being triggered since it was the same!

    My fix for it:
    Code:
        // must reset the actual form in order to properly function
        // This fixes the bug: select file, reset, select same file
        reset : function() {
          Ext.get(this.getFileInputId()).findParentNode("form").reset();
          Ext.form.FileUploadField.superclass.reset.call(this);
        },
    I wasn't sure any other way to find the parent form since the object itself is just the field.

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default DUP

    DUP


    Duplicate of this post (different solution though).

  3. #3
    Ext User
    Join Date
    Jul 2009
    Posts
    27
    Vote Rating
    0
    amodg is on a distinguished road

      0  

    Default


    Hi azbok,

    I have tested this fix with a little change. I was getting an error 'Ext.get(this.getFileInputId()) is null'

    reset : function() {
    var fileObj = Ext.get(this.getFileInputId());
    if(fileObj){
    fileObj.findParentNode("form").reset();
    }
    Ext.form.FileUploadField.superclass.reset.call(this);
    }


    It works fine in FF3 and IE8.
    Thanks for the solution.
    -Amod

Thread Participants: 2