473,326 Members | 2,680 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,326 software developers and data experts.

calling methods within a prototype (oo) way

Hi,

I have 2 methods defined within a javascript objects
that I would like to call in a third function within the same object.
In the example below, func3 works well in FF but in IE7 it breaks.

Any suggestions about how this may work ? I am sure this has to do
with notation.
I am calling the methods statically - so not instantiating a objects
first.

TIA,
Tuka

i.e.

in a prototype object

this.func1 = function(args) {
//do stuff
}

this.func2 = function(args) {
//do stuff
}

this.func3 = function(args) {
this.func1();
this.func2();
}
Apr 1 '08 #1
1 1442
On Apr 2, 8:13 am, tuka <tukaopal...@googlemail.comwrote:
Hi,

I have 2 methods defined within a javascript objects
that I would like to call in a third function within the same object.
In the example below, func3 works well in FF but in IE7 it breaks.

Any suggestions about how this may work ? I am sure this has to do
with notation.
I am calling the methods statically - so not instantiating a objects
first.

TIA,
Tuka

i.e.

in a prototype object

this.func1 = function(args) {
//do stuff

}

this.func2 = function(args) {
//do stuff

}

this.func3 = function(args) {
this.func1();
this.func2();

}
It's always good to post working code (or at least code that, when
executed, demonstrates the problem or issue) that can be easily copied
and pasted.

The following works fine in Firefox and IE at least:

function Foo(){
}

Foo.prototype = {
func1: function(){alert('func1');},
func2: function(){alert('func2');},
func3: function(){this.func1();}
};
var foo = new Foo();
foo.func3(); // --func1
--
Rob
Apr 2 '08 #2

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

Similar topics

4
by: Gibby Koldenhof | last post by:
Hiya, I'm setting up some code in the spirit of Design Patterns, OOP, etc. All nice and well, it handles pretty much all OO style things and serves my purposes well. There's one last final...
7
by: John | last post by:
Hi I have two distinct classes A & B. I am using class B from within Class A as follows; Public Class clsClassA Friend ClassB As new ClassB Public Sub New()
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
12
by: torbs | last post by:
Hi I have a a function with several methods. For simplicity it looks a bit like this: super.prototype.aProperty="HELLO"; super.prototype.returnValue = function () { return 2;
3
by: rickeringill | last post by:
Hi comp.lang.javascript, I'm throwing this in for discussion. First up I don't claim to be any sort of authority on the ecmascript language spec - in fact I'm a relative newb to these more...
26
by: Cliff Williams | last post by:
Can someone explain the pros/cons of these different ways of creating a class? // 1 function myclass() { this.foo1 = function() {...} } // 2a
3
by: jacobstr | last post by:
I've noticed Object.extend used in a few different ways and I'm having trouble distinguishing why certain usages apply to a given situation. On line 804 Ajax.Base is defined as follows: ...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
5
by: bizt | last post by:
Hi, Below I have a simple object / function thing (still getting head round these) declaration: function MyObject() { this.alertMe = function() { alert('hello'); }; this.alertMeAgain() {
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...
1
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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

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.