PDA

View Full Version : new to Sencha, need a kick to start started - Problem with class creation



caleem@gmail.com
10 Oct 2012, 5:01 PM
hi,
I have created following class for Sencha, but it doesn't show the alert message.
Can someone tell me whats wrong with the code?

Also 1. do i need tp copy Person class under a separate file under folder structure My\sample ??
2. if there is any error how can I check that, I am using trial version and google chrome.

comments and suggestion are appropriated, thank you...
here is the code below.

Ext.application({


name: 'HelloExt',
launch: function(){

Ext.define('My.sample.Person',{
name: 'John';
constructor: function (name){
if (name){
this.name = name;
}
}

eat: function(foodtype){
alert(this.name + ' is eating ' + foodtype );
}
});


var k = Ext.create('My.sample.Person', 'JJ');
k.eat('fishhh');

}


});

vietits
10 Oct 2012, 5:32 PM
1. do i need tp copy Person class under a separate file under folder structure My\sample ??

If you just need to check a class, you can put it directly in your code as you did with your example. However, it is often a class is used for more than one place in your code, so you should put it in a separate file. You should look at this manual to see more information about naming classes, where to store them, etc : http://docs.sencha.com/ext-js/4-1/#!/guide/class_system


2. if there is any error how can I check that, I am using trial version and google chrome.

You should use Tools\Developer tools which is included in Chrome.

Below are some errors in your code:


Ext.application({
name: 'HelloExt',
launch: function(){
Ext.define('My.sample.Person',{
name: 'John', // ; <- comma instead of semicolon
constructor: function (name){
if (name){
this.name = name;
}
}, // missing comma
eat: function(foodtype){
alert(this.name + ' is eating ' + foodtype );
}
});


var k = Ext.create('My.sample.Person', 'JJ');
k.eat('fishhh');
}
});

P/S: You should put your code by using CODE tag, then you will have more opportunity of getting support from community.

caleem@gmail.com
12 Oct 2012, 2:46 PM
its working fine now,

is there any way where I can check the error log ??

there should be some place where I can check the log and come to know that i have added semi colon inplace of comma.

<code>
Ext.application();
</code>

caleem@gmail.com
12 Oct 2012, 2:47 PM
<CODE>
Ext.Application();
</CODE>

vietits
12 Oct 2012, 3:38 PM
Just use Tools\Deverloper tools that comes with Chrome browser.