PDA

View Full Version : my function is not a function ^^



yannickiwi
19 Mar 2009, 6:19 AM
Hi,

I have this code:


var displayAddProject = new Ext.Window({
title: 'Ajouter un nouveau projet',
id: 'addproject',
width: 500,
height: 500,
items: new Ext.form.FormPanel({
height: 500,
items:[{
xtype: 'textfield',
fieldLabel: 'Référence',
id: 'ref',
name: 'ref',
maxLength: 45, // basic validation, maximum characters
allowBlank: false,
emptyText:'Entrez une référence',
anchor: '100%'
},{
xtype: 'combo',
store: clientStore,
displayField:'lastName',
name: 'lastName',
fieldLabel: 'Client(e)',
emptyText:'Sélectionner un(e) client(e)',
typeAhead: true,
triggerAction: 'all',
selectOnFocus:true,
allowBlank: false,
mode: 'remote',
anchor: '100%'
},{
xtype: 'textfield',
fieldLabel: 'Nom du projet',
id: 'name',
name: 'name',
maxLength: 45, // basic validation, maximum characters
allowBlank: false,
emptyText:'Entrez un nom pour le projet',
anchor: '100%'
}]
}),
buttons: [{
text: 'Sauvegarder',
handler: function(){
displayAddProject.getForm().submit({
url: '/set/project/updateProject/write/', // in here you can put the server proxy page
// params:{id: 'test'}, // extra parameters sent to the server along with the form data
waitTitle:'Sauvegarde',
waitMsg:'Sauvegarde en cours...',
success: function(f,a){
projectStore.reload(); // reload method of a store, uses last load options
displayAddProject.hide();
},
failure: function(f,a){
Ext.Msg.alert('Echec de la sauvegarde du nouveau projet.');
}
});
}
},{
text: 'Annuler',
handler: function(){
displayAddProject.hide();
}
}]
});

When I click on my "Submit" button, I have this error:


displayAddProject.getForm is not a function
chrome://firebug/content/blank.gif displayAddProject.getForm().submit({


I don't understand Because I use exactly this code on a panelForm:


var EditTask =...
...
handler: function(){
editTask.getForm().submit({
url: '/set/task/updateTask/write/', // in here you can put the server proxy page
// params:{id: 'test'}, // extra parameters sent to the server along with the form data
waitTitle:'Sauvegarde',
waitMsg:'Sauvegarde en cours...',
success: function(f,a){
//callTaskData(); -> wrong
taskStore.reload(); // reload method of a store, uses last load options
editTask.getForm().reset();
},
failure: function(f,a){
Ext.Msg.alert('Oups, système momentanément inaccessible');
}
});
}
}
...


and that's okay. But this editTask "function" isn't into a window Form. Do you understand ?

Animal
19 Mar 2009, 6:30 AM
displayAddProject is a Window:



var displayAddProject = new Ext.Window({


Hmm?

Ext.Window does not have a getForm method.

19 Mar 2009, 6:31 AM
displayAddProject.items.items[0].getForm().sumbit

yannickiwi
19 Mar 2009, 6:36 AM
gracias :)