br******@gmail. com wrote:
I've been working on improving my javascript coding and decided to
start using classes.
But you could not and did not, as the languages you are using have no
concept of classes. They are object-oriented programming languages using
prototype-based inheritance:
http://javascript.crockford.com/javascript.html
I've gotten pretty far but am having problems
attaching a member function to a control event.
"Member" is a term from class-based thinking; it does not apply here.
CBonfireStore.p rototype.setupC lick = function( obj )
You should remove the leading `C' if it is only there to indicate that
`CBonfireStore' was a class and would therefore promote the misconception
of the existence of classes in the used languages to the uninitiated developer.
Usually constructors for a prototype object, which is what `CBonfireStore'
actually refers to, have reference identifiers starting with a capital
letter to distinguish them from other identifiers, and in that sense
`BonfireStore' would suffice.
{
obj.onclick = function(){ this.incrementC licked(obj); };
Use DOM Level 2 Event methods to assign event listeners, and proprietary
approaches only when necessary. See also _addEventListen er() in
http://PointedEars.de/scripts/dhtml.js (updated recently, see
http://PointedEars.de/scripts/dhtml.js.diff)
obj.style.curso r = 'pointer';
}
You should use the more interoperable spaces for indentation, not tabs.
The above does not work.
http://www.jibbering.com/faq/faq_not...ml#ps1DontWork
If I take away the this. infrom of the incrementClicke d(obj),
and point to a non-member version of the function,
It is also a misconception that globally declared functions would not be
methods; they are methods of the Global Object which is found through
identifier resolution along the scope chain.
every works OK.... but that's not what I want.
It would appear that the problem is in incrementClicke d() which you have not
posted.
I do I get this to use the method of the current instance?
This sentence sense.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8************ *******@news.de mon.co.uk>