2016-09-07 8 views
0

filefieldコンポーネントで重大な問題が発生したため、ExtJs 4.1からExtJs 4.2に移動しました。主な問題は、ExtJs 4.1では、各フォーム提出の後にファイルフィールドがクリアされたことでした。このthreadによれば、ExtJs 4.2で問題を解決しましたが、clearOnSubmitfalseに設定したにもかかわらず、私のアプリケーションではまったく同じ問題に直面しています。clearOnSubmit falseのファイルフィールドはまだクリアされています

<input id="filefield-2144-button-fileInputEl" class=" x-form-file-input" type="file" size="1" name="file_name" role=""> 

と置き換えます:フォームがサーバーに送信し、最初の要素をdestroyesされている場合、このライブラリー法は、いくつかの時点で呼び出され

Ext.define('Ext.form.field.FileButton', { 
    ... 
createFileInput : function(isTemporary) { 
    var me = this; 
    //ATTENTION! 
    //before me.el.createChild is called 
    //me.fileInputEl contains initial filefield: 
    //<input id="filefield-2144-button-fileInputEl" class=" x-form-file-input" type="file" size="1" name="file_name" role=""> 
    me.fileInputEl = me.el.createChild({ 
     name: me.inputName, 
     id: !isTemporary ? me.id + '-fileInputEl' : undefined, 
     cls: me.inputCls, 
     tag: 'input', 
     type: 'file', 
     size: 1 
    }); 
    //ATTENTION! 
    //now initial fielfield is gone, even though we have set clearOnSubmit to false 
    me.fileInputEl.on('change', me.fireChange, me); 
    } 
... 

:私もコードが全体の問題の原因を考え出しました

<input name="file_name" id="ext-gen4414" class="x-form-file-input" type="file" size="1"> 

このライブラリのバグを修正するにはどうすればよいですか。

答えて

2

4.2.1でテストしました。ファイルフィールドは送信後にクリアされません。

Ext.application({ 
    name: 'Fiddle', 

    launch: function() { 
     Ext.create('Ext.form.Panel', { 
      title: 'Upload a Photo', 
      width: 400, 
      bodyPadding: 10, 
      frame: true, 
      renderTo: Ext.getBody(), 
      items: [{ 
       xtype: 'filefield', 
       name: 'photo', 
       fieldLabel: 'Photo', 
       labelWidth: 50, 
       msgTarget: 'side', 
       allowBlank: false, 
       anchor: '100%', 
       buttonText: 'Select Photo...', 
       clearOnSubmit: false 
      }], 

      buttons: [{ 
       text: 'Upload', 
       handler: function() { 
        var form = this.up('form').getForm(); 
        if (form.isValid()) { 
         form.submit({ 
          url: 'photo-upload.php', 
          waitMsg: 'Uploading your photo...', 
          success: function(fp, o) { 
           Ext.Msg.alert('Success', 'Your photo "' + o.result.file + '" has been uploaded.'); 
          } 
         }); 
        } 
       } 
      }] 
     }); 
    } 
}); 
+1

このためのフィドラー。 https://fiddle.sencha.com/#fiddle/1gd2 – UDID

関連する問題