[ 8 posts ] 
Author Message
 Post subject: HELP! Problems with passing variable between stage and model
PostPosted: Sat Oct 10, 2009 5:03 am 

Joined: Sat Oct 10, 2009 4:37 am
Posts: 100
So I have been trying to get this working for awhile. I am trying to send data from alarm-assistant.js to alarm.js and use it to set a variable. Please if you can help take a quick look and let me know.

This I how I setup my ListSelector command in alarm-assistant.js:

Code:
var AlarmAssistant = Class.create({
snoozetimes: [
            {label:$L('5 Min'), value:"00:05:00"},
                {label:$L('10 Min'), value:"00:10:00"},
                {label:$L('15 Min'), value:"00:15:00"},
                {label:$L('20 Min'), value:"00:20:00"}
        ],
       setup: function() {
                //Snooze Widget
                this.snoozeselectorsModel={snoozeStatus: this.alarm.snoozetime};
                this.controller.setupWidget('snoozelength', {label: $L('Snooze'), choices: this.snoozetimes, modelProperty:'snoozeStatus'}, this.snoozeselectorsModel);
                this.controller.listen('snoozelength', Mojo.Event.propertyChange, this.snoozeChanged.bindAsEventListener(this));
        },
snoozeChanged: function(e){
                this.alarm.saveSnooze(e.value);
        },
});


I believe I have that all set up correctly. everything in the UI works correctly and look right. but it does not seem like the values from the ListSelector are being set.

here is my code from alarm.js

Code:
var Alarm = Class.create({
        initialize: function(id) {
                                        snoozetime = "00:10:00";
                                        }

        saveSnooze: function(snoozetime){
                this.snoozetime = snoozetime;
         };
});

SnoozeDuration = this.snoozetime;


snoozetime does not take the variable from the ListSelector in the assistant file. What is wrong with my code? I dont know why the variable is not being stored or transfered over.

Thanks for the help

_________________
Rocking out Pre 1.4.5 and TP 3.0.2

Published TP Apps:
Anagramarama HD

Published Phone Apps
Anagramarama
DDII Free


Last edited by elpollodiablo1 on Sun Oct 11, 2009 1:27 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: NEED HELP!! Problems with variables set in ListSelector
PostPosted: Sat Oct 10, 2009 5:21 am 

Joined: Fri Oct 09, 2009 1:15 pm
Posts: 28
yaaa problem is that you to bind ur function lik thisd


saveSnooze:this.snoozetime.bind(this);

this.snoozetime = snoozetime;

function(snoozetime)
----------------------------------------------------------------

define like this
your assistant.prototype.snoozetime=function(snoozetime)
{
this.snoozetime = snoozetime;
}


Top
 Profile  
 
 Post subject: Re: NEED HELP!! Problems with variables set in ListSelector
PostPosted: Sat Oct 10, 2009 5:34 am 

Joined: Sat Oct 10, 2009 4:37 am
Posts: 100
could you elaborate, I am not sure I understand what you were trying to say. thanks for the reply

_________________
Rocking out Pre 1.4.5 and TP 3.0.2

Published TP Apps:
Anagramarama HD

Published Phone Apps
Anagramarama
DDII Free


Top
 Profile  
 
 Post subject: Re: NEED HELP!! Problems with variables set in ListSelector
PostPosted: Sat Oct 10, 2009 6:30 am 

Joined: Fri Oct 09, 2009 1:15 pm
Posts: 28
saveSnooze: function(snoozetime){
this.snoozetime = snoozetime;
};


replcae it with

saveSnooze:this.setSnoozetime.bind(this);


and define function

your assistant.prototype.setSnoozetime=function(snoozetime)
{
this.snoozetime = snoozetime;
}


Top
 Profile  
 
 Post subject: Re: NEED HELP!! Problems with variables set in ListSelector
PostPosted: Sat Oct 10, 2009 2:31 pm 

Joined: Sat Oct 10, 2009 4:37 am
Posts: 100
could you explain why my bind structure didnt work and why you chose to do it that way? so I have a better understanding for the future. and I still cant get the

AppAssistant.prototype.setSnoozetime=function(snoozetime)
{
this.snoozetime = snoozetime;
},

I know I need to define that function but what file do I define it in? app-assistant.js? alarm-assistant.js or alarm.js?
I already tired to define it in alarm.js and app-assistant.js but didnt work either time.

are there any examples about defining variables and using them across different js files?

I have not worked with javascript and WebOS very long so I am still trying to learn about handles, listen, binds and how it should be structured and defined.

Thanks for the help

_________________
Rocking out Pre 1.4.5 and TP 3.0.2

Published TP Apps:
Anagramarama HD

Published Phone Apps
Anagramarama
DDII Free


Top
 Profile  
 
 Post subject: Re: HELP! Problems with passing variable between stage and model
PostPosted: Mon Oct 12, 2009 6:11 am 

Joined: Fri Oct 09, 2009 1:15 pm
Posts: 28
send me ur code ,

i will check it.............


Top
 Profile  
 
 Post subject: Re: HELP! Problems with passing variable between stage and model
PostPosted: Mon Oct 12, 2009 2:33 pm 

Joined: Tue Aug 25, 2009 8:30 am
Posts: 44
where in AlarmAssistant did u define this.alarm?

put
Code:
this.alarm = new Alarm();

in AlarmAssistants setup().

by the way:
using try/catch REALLY saves A LOT of time...


Top
 Profile  
 
 Post subject: Re: HELP! Problems with passing variable between stage and model
PostPosted: Wed Oct 14, 2009 1:15 am 

Joined: Sat Oct 10, 2009 4:37 am
Posts: 100
I just used the code from the default "Clock" application and added in my code to try and get a snooze time setup. The only two files I originally made any changes to were /app/model/alarm.js and /app/controllers/alarm-assistant.js

I have these files if anyone wants to help me out and look at them.

You can find them here. http://forums.precentral.net/webos-patches/207008-patch-project-adding-snooze-time-alarm.html

_________________
Rocking out Pre 1.4.5 and TP 3.0.2

Published TP Apps:
Anagramarama HD

Published Phone Apps
Anagramarama
DDII Free


Top
 Profile  
 
Display posts from previous:  Sort by  
   [ 8 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron