Hi! Thanks T.J and Colin.

So Far So Good!

I stayed with the 'inline method', to save code.

I could Not get the bind() to work within the Ajax.Request though??
I tried it as T.J showed, and several other ways.
Firebug reported different errors.
Suggested method for inline returned (' missing } from property
statement') with parenthes ')' and
syntax errors without them.
Trying in other positions had similar errors..

One odd bit of behaviour noted though.
After populating the arrays and after exiting the Ajax.functions, when
I did 'alert(this.cap_questions) before the method finished only got a
blank result, not undefined, just blank.
I figured that self = this is like using the PHP & operator which
binds the new var to the original?
I even tried to alert(self.cap_questions) and got the same blank
result.
Yet, the arrays where populated as expected?? I guess part of the game
is having faith in what your doing!

I used the 'var self = this;'  Worked like a dream - thanks.

I did use the bind() in a few other places, like inside some
setTimeout's - where I wrap in a function() as per LINT methods..

I definately learnt a few new things tonight. Much appretiated. I
relate a lot to my PHP Classes and basic JS knowledge, but I'll have
to do some homework on Prototype Classes and Js Classes and Objects.
My Js function days are over. Classes from now on..

The second issue about calling one method from within another resolved
itself using the bind().

I also did a quick test, regarding what you said about 'global vars'.
I set a var in one method and tested for in in the next one that runs,
but it returned 'undefined'..
I did tidy up the vars as you suggested though!

I'll study the links that you gave me to see if I can undeestand how
globals (declared vars) run their scope in Js classes.
I think thats the key issue with all od this, scope..

I know that globals can be a bad thing as per ADSafe specs..

I'm going to be re-writing most of my JS into classes now, so you may
hear from me again on classes if I get stuck..

I have another problem with prototype that I want to ask about, but as
its not related so I'll start a new thread tommorow.
Its bedtime now here in Oz..

Thanks again for your prompt help. This is a great group.
Signing Off - Gilbert R
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to