Need help for creating Apps. I have two queries. Please help me in this regard

kpramc
User offline. Last seen 1 week 3 days ago. Offline
Joined: 03/25/2011
Points: 20

1. I want to create the jsclass object inside the app.js file.  which is requires constructor parameter app. I dont know how to provide the app parameter. example

Sample.SampleClass =function(app) {

//by default app parameter have values and i can able to access.

}

//here i wrote some function outside of the class.

function test()

{

 var obj= new Sample.SampleClass( ?); // ? - how to I have to mentioned the app parameter for that constructor.

}

  So, please help me to create and call that class.

And Second question is,

In Prototype class,  is there any default method behaviors?. like receive, load something.

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 2 weeks 5 days ago. Offline
Joined: 08/29/2008
Points: 34

Well, it's not that complicated. You don't have to create the var obj to instanciate the custom App object. The App Framework already does that for you and pass it as a parameter to the constructor function.

So in the sample code: 

Sample.SampleClass = function(app) { //app constructor logic here};

The parameter "app" is the App object instance.  Simply add any logic you need to construct the App for your purposes inside the anonymous function. For a basic example of this at work, please see http://www.jackbe.com/prestodocs/v3.0/apps-dev/createSimpleGrid.html. Most especially, check out the section on defining the App Constructor (http://www.jackbe.com/prestodocs/v3.0/apps-dev/createSimpleGrid.html#jbid113VF0T80PF).

You can also do the constructor using the onLoad(app) method, but the docs for this are not yet up on the doc site. Will be available this week for sure.

Sara, technical writer/jackbe