473,698 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.protot ype = {
initialize: function(elemen t) {
//...
},
// 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 1231
pe**********@ya hoo.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.protot ype = {
initialize: function(elemen t) {
//...
},
// 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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 9 '06 #2
pe**********@ya hoo.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.classM ethod = function classMethod(lal a) { /* ... */ };

(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/rasterTriangleD OM.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**********@ya hoo.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**********@ya hoo.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**********@ya hoo.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_programmi ng.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/rasterTriangleD OM.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
3831
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 experts. I would like to produce Javascript classes that can be "subclassed" with certain behaviors defined at subclass time. There are plenty of ways to do this through prototyping and other techniques, but these behaviors need to be static and...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2333
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.