PDA

View Full Version : Can't get the router to work: myapp not defined



Gunmen
7 Feb 2010, 12:45 PM
This is my ASHX response:


Ext.app.USER_API = {"type":"remoting","url":"/firstapp/con/con.ashx","namespace":"Myapp","actions":{"Users":[{"name":"Login","len":1,"formHandler":true}]}};


This is a part of my form panel:


id:'my_login',
xtype:'form',
api: {
submit: 'Myapp.Users.Login'
},
items:[{
fieldLabel:'Username',
name:'username',
allowBlank:false
},{


While loading my site, I receive the error message:


Myapp is not defined


Found: added quotes!
Now I receive the error message: this.form.api.submit is not a function.

evant
7 Feb 2010, 4:36 PM
Adding quotes is incorrect, the api should refer to a JS method.

Gunmen
8 Feb 2010, 1:43 AM
Hi!

Well, I'm looking at your example code, see below:



var form = new Ext.form.FormPanel({
title: 'Form Upload',
flex: 1,
bodyStyle: 'padding: 15px;',
api: {
load: MyApp.Sample.LoadForm,
submit: MyApp.Sample.SubmitForm
},
listeners: {
actioncomplete: function(form, e){
if(e.type == 'directsubmit'){
var d = e.result.data,
name = d.firstName + ' ' + d.lastName;
Ext.Msg.alert('Hello', 'Hi ' + name + ', you are ' + d.age);
}
}
},
items: [{
xtype: 'textfield',
name: 'firstName',
fieldLabel: 'First Name'
}, {
xtype: 'textfield',
name: 'lastName',
fieldLabel: 'Last Name'
}, {
xtype: 'numberfield',
name: 'age',
fieldLabel: 'Age'
}],
buttons: [{
text: 'Load',
handler: function(){
form.getForm().load();
}
},{
text: 'Submit',
handler: function(){
form.getForm().submit();
}
}]
});


Okay, no quotes. However, MyApp.Sample.SubmitForm is the same as Myapp.Users.Login (even the upper and lower cases are correct). And when you look at my ashx reponse you see that there is a Users.Login function.

Where do you think I need to look at?

Gunmen
8 Feb 2010, 9:30 AM
Hi!

When I remove the quotes, I receive the js error that Myapp is not defined. Is my ashx response incorrect? I need a hint. I'm using your .NET Router, the group version.

For so far I can see, I have written the same code as in your example. Can it be that I'm using the MS Visual Web Developer???

Thanks again!