All pastes #461913 Raw Edit

Anonymous

public text v1 · immutable
#461913 ·published 2007-04-27 22:46 UTC
rendered paste body
var ulImgForm = new Ext.form.Form({
	fileUpload: true
});

ulImgForm.add(
    new Ext.form.Field({
        fieldLabel: 'Upload',
        name: 'file',
		inputType: 'file'
    })
);

ulImgForm.addButton('create', function(){
	 ulImgForm.submit({
		waitMsg: 'Processing Data, please wait...',
		reset: false,
		success: function(){console.log('[success]');},
		invalid: function(){console.log('[invalid]');}, //???????
        failure: function(f,e){
        	console.log('[failure]');
	        if(e.failureType == 'server'){
    		    Ext.Msg.alert('Failure server', 'id:' + e.result.errors.id + ' - msg:' + e.result.errors.msg);
            }else{
               Ext.Msg.alert('Failure client', 'Validation failed');
            }		
	    },
		params: {action: 'new'}
	});
});

ulImgForm.on('actioncomplete', function(form, action){
	console.log('actioncomplete');
     var type = action.type; // e.g. "load"
     var data = action.result; // your full json data pre parsed
     console.log('action.type: '+type);
     console.log('action.data: '+data);
     console.log('data.blah: '+data.blah);
});

ulImgForm.on('actionfailed', function(form, action){
	console.log('actionfailed');
	//console.log('action.type: '+action.type);
     //console.log('action.data: '+action.data);
     if(action.type == 'submit' && 
          action.failureType == Ext.form.Action.SERVER_INVALID){
          // server side validation failed
     }
});

ulImgForm.render(Ext.get("south"));

//success will return json: {success: true, data: {"foo":"bar"}}
//failure should return what???