473,378 Members | 1,416 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,378 software developers and data experts.

Move Prototype's Function Outside?

How do I place a function outside of the, so called, "class" in
prototype.js?

Example: Here is a standard way to write a class using prototype.js.

var Person = Class.create({
initialize: function(name) {
this.name = name;
},
say: function(message) {
return this.name + ': ' + message;
}
});

I want the function "say" to be outside of class like:

var Person = Class.create({
initialize: function(name) {
this.name = name;
},
say : sayOutside // <-------moved out
});

function sayOutside(message) {
return this.name + ': ' + message;
}
Dec 4 '07 #1
4 1278
VUNETdotUS said the following on 12/4/2007 3:27 PM:
How do I place a function outside of the, so called, "class" in
prototype.js?
You go to one of the prototype forums (search the archives) and ask
someone who supports it how to do what you want.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 4 '07 #2
On Dec 4, 4:22 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
VUNETdotUS said the following on 12/4/2007 3:27 PM:
How do I place a function outside of the, so called, "class" in
prototype.js?

You go to one of the prototype forums (search the archives) and ask
someone who supports it how to do what you want.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
I'll try their forums. However I thought Prototype is just a JS with
functions and methods to simplify stuff. I wonder how do JS experts
treat prototype anyway?
Dec 5 '07 #3
On Dec 5, 11:25 am, VUNETdotUS <vunet...@gmail.comwrote:
On Dec 4, 4:22 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
VUNETdotUS said the following on 12/4/2007 3:27 PM:
How do I place a function outside of the, so called, "class" in
prototype.js?
You go to one of the prototype forums (search the archives) and ask
someone who supports it how to do what you want.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/

I'll try their forums. However I thought Prototype is just a JS with
functions and methods to simplify stuff. I wonder how do JS experts
treat prototype anyway?
Like a red-headed stepchild.
Dec 5 '07 #4
VUNETdotUS said the following on 12/5/2007 11:25 AM:
On Dec 4, 4:22 pm, Randy Webb <HikksNotAtH...@aol.comwrote:
>VUNETdotUS said the following on 12/4/2007 3:27 PM:
>>How do I place a function outside of the, so called, "class" in
prototype.js?
You go to one of the prototype forums (search the archives) and ask
someone who supports it how to do what you want.

I'll try their forums. However I thought Prototype is just a JS with
functions and methods to simplify stuff.
Depends on how you define "simplify" stuff. Most of it so convoluted
that altering it is anything but "simple". I have looked at the code in
it twice in its entirety. Other than that, I have only seen snippets of
it posted here and most aren't worth using for anything other than a
"you shouldn't do it this way".
I wonder how do JS experts treat prototype anyway?
Most of them view it as an ill-fated attempt to try to create an
all-in-one library that is best avoided like a plague. The people that
are qualified to tell you the best way to modify it are the same people
that will tell you it isn't worth modifying.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 5 '07 #5

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

Similar topics

8
by: Elf M. Sternberg | last post by:
One of the complaints about prototype.js (google for it if you're not familiar with it) is that it's poorly documented. I have this inkling that the key to understanding prototype.js is in the...
8
by: Robert | last post by:
Hi, I can use "with" like this: function MyObject(message) { this.message = message; } function _MyObject_speak() {
4
by: lkrubner | last post by:
I'm reading an essay, I think one of Crockford's, and it has this example in it: function Demo() { } Demo.prototype = new Ancestor(); Demo.prototype.foo = function () { } ; Does Ancestor now...
21
by: Rob Somers | last post by:
Hey people, I read a good thread on here regarding the reason why we use function prototypes, and it answered most of my questions, but I wanted to double check on a couple of things, as I am...
2
by: None | last post by:
Hello, 1. The prototype of function signal in signal.h: void (*signal(int sig, void (*func)(int)))(int); is some complex to me. Would you please explain it to me in detail with the C...
14
by: Gerald S | last post by:
hi, got a performance problem; situation is as described below (see "Version Inline"), i've got a javascript class item with many methods defined inside and with every call to "new item()" the...
6
by: Robbie Hatley | last post by:
I'm maintaining a software project with 134 C++ files, some of them huge (as much as 10,000 lines each), and very few prototypes. The author's attitude towards prototypes was like this: ...
5
by: Daz | last post by:
Hi everyone. My query is very straight forward (I think). What's the difference between someFunc.blah = function(){ ; } and
1
by: p.tilhoo | last post by:
Hello there, I am a programmer mostly using c# and just started using Javascript. I am trying to use prototype to declare and use an object and having difficulties in coding for nested...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.