473,324 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Classes in Javascript using Prototype library

Hi,

I've been using the prototype.js library[1] to create classes.
Something like

var Sortable = Class.create();
Sortable.prototype = {
initialize: function(element) {
//...
},
// more methods...
}

All of my methods are instance methods. What is the tidiest way to
create class methods and variables?

Thanks,
Peter

[1] - http://prototype.conio.net/

Feb 9 '06 #1
6 1218
pe**********@yahoo.com said the following on 2/9/2006 2:58 PM:
Hi,

I've been using the prototype.js library[1] to create classes.
Something like

var Sortable = Class.create();
Sortable.prototype = {
initialize: function(element) {
//...
},
// more methods...
}

All of my methods are instance methods. What is the tidiest way to
create class methods and variables?


You ask the people at http://prototype.conio.net/ and let them answer
you since it is a technical support question for a piece of software you
want.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 9 '06 #2
pe**********@yahoo.com writes:
I've been using the prototype.js library[1] to create classes. .... var Sortable = Class.create(); .... All of my methods are instance methods. What is the tidiest way to
create class methods and variables?


I don't know the prototype library (for help specific to that, I would
guess that they have a web forum somewhere), but what I would do is

Sortable.classMethod = function classMethod(lala) { /* ... */ };

(I'm not particularly fond of the idea of emulating class based
programming in a prototype based language. It's never going to
be exactly what you expect. Ofcourse it's faster than actually
learning prototype based programming, something I won't claim to
have done myself to the level I would prefer :).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Feb 10 '06 #3
Lasse Reichstein Nielsen wrote:
I'm not particularly fond of the idea of emulating class based
programming in a prototype based language. It's never going to
be exactly what you expect. Ofcourse it's faster than actually
learning prototype based programming, something I won't claim to
have done myself to the level I would prefer :).


Ok, that sounds really reasonable. How do I go about learning how to
program a prototype-based language in it's native way? I've read about
prototypes but don't feel at all intuative with them yet. I'm reading
online articles right now but haven't found the one that makes the
fundamental idea click yet.

-Peter

Feb 10 '06 #4
VK

pe**********@yahoo.com wrote:
I'm reading
online articles right now but haven't found the one that makes the
fundamental idea click yet.


encapsulation

encapsulation lo

prototype chain

screw the rules

I'm free!

:-)

Feb 10 '06 #5
Thanks VK.

(ummm. Anyone else?)

Peter

VK wrote:
pe**********@yahoo.com wrote:
I'm reading
online articles right now but haven't found the one that makes the
fundamental idea click yet.


encapsulation

encapsulation lo

prototype chain

screw the rules

I'm free!

:-)


Feb 10 '06 #6
pe**********@yahoo.com writes:
How do I go about learning how to program a prototype-based language
in it's native way? I've read about prototypes but don't feel at all
intuative with them yet. I'm reading online articles right now but
haven't found the one that makes the fundamental idea click yet.


You can try this one:
<URL:http://www.zwetan.com/files/Prototype-based_programming.pdf>
I haven't read it yet, only scanned the headlines, but it looks
promising.
Another good guess is Googling for "prototype based programming".

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Feb 10 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Kevin Prichard | last post by:
Hi all, I've recently been following the object-oriented techiques discussed here and have been testing them for use in a web application. There is problem that I'd like to discuss with you...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.