PDA

View Full Version : fileuploadfield will not render properly 2nd time



vasion
1 Feb 2010, 6:54 AM
i am having the weirdest problem. i have a form with fileupload in a window. when i call it the first time its all fine. when i upload a file and then try to do the same thing, i get the field label 2 times and no upload field. I have attached screenshot, i am sorry it is not in English, but it should be pretty straight forward.

does anybody have any idea what is going wrong.

here is my code.

type and id are php vars and are passed just fine.


function newpic(){
type='<?=$type;?>';
modelid='<?=$id;?>';

win = new Ext.Window({title:"???? ???? ??????",layout:'fit'});

var fp = new Ext.FormPanel({
fileUpload: true,
width: 500,
autoHeight: true,
frame: true,
bodyStyle: 'padding: 10px 10px 0 10px;',
labelWidth: 50,
defaults: {
anchor: '95%',
allowBlank: false,
msgTarget: 'side'
},
items: [
{
xtype: 'fileuploadfield',
id: 'form-file',
emptyText: '???????? ??????',
fieldLabel: '??????',
name: 'uploadedphoto',
buttonText: '',
buttonCfg: {
iconCls: 'upload-icon'
}
}],
buttons: [{
text: '??????',
handler: function(){
if(fp.getForm().isValid()){
fp.getForm().submit({
url: '/tachi/admins/addpicture/'+type+'/'+modelid,
waitMsg: '??????? ?? ????????',
success: function(fp, o){
win.hide();
Ext.Msg.alert('???????? ?? ????????', o.result.msg);
storepics.reload();
},
failure: function(fp, o){
win.hide();
Ext.Msg.alert('????????? ???????', o.result.msg);
}
});
}
}
},{
text: '??????',
handler: function(){
fp.getForm().reset();
win.hide();
}
}]
});
win.add(fp);
win.show();
}

realjax
1 Feb 2010, 7:38 AM
Depending on how you call the window the second time, it just might be because you add fp again...

vasion
1 Feb 2010, 8:05 AM
well i just call the function twice. if i call it once cancel the window, and then call it again, it works. if i actually upload smt it gives me this error.

could this be a bug?

vasion
1 Feb 2010, 12:41 PM
for those who stumble upon the same problem. hide() is not the right function. close() removes the window from the DOM. it is so obvious i am angry at myself for not reading the api more carefully in the morning when i discovered the problem