Hi.
I am wondering what do I replace the "this"
statement with to get the appropriate container/response.
When I try:
cal.prototype.d ates(cal.days[i].day);
I get
"this.cells has no properties"
And, in the function declaration (within which lives 'dates'),
there is:
function MyCal()
{
this.cells = new Array();
...
The thing is (and this is key) I am calling
cal.prototype.d ates(cal.days[i].day) from a completely
different script (which references a different part of the
HTML on the page).
How do I refer to the container of the
"this" in the "this.cells has no properties" error? 4 1475
On Sep 19, 2:01 pm, pbd22 <dush...@gmail. comwrote:
Hi.
I am wondering what do I replace the "this"
statement with to get the appropriate container/response.
When I try:
cal.prototype.d ates(cal.days[i].day);
I get
"this.cells has no properties"
And, in the function declaration (within which lives 'dates'),
there is:
function MyCal()
{
this.cells = new Array();
...
When you call a method on a function's prototype object, the "this"
keyword (which is a keyword, not a statement) refers to the prototype
object, not to any specific instance. Since it looks like
"this.cells " is assigned in the constructor to MyCal, my guess is
you're using the "prototype" reference when you mean the instance
itself. Try:
cal.dates(cal.d ays[i].day);
though I have no idea whether this will work, since I know nothing
about the "dates" method, or how you have defined the identifier
"cal".
The thing is (and this is key) I am calling
cal.prototype.d ates(cal.days[i].day) from a completely
different script (which references a different part of the
HTML on the page).
Actually, and this will probably surprise you, but that's NOT key -
that should actually have nothing to do with it. All script files in
the same window (or frame) share the same global namespace, aka the
window object, regardless of where their script tags are on the page.
There's no standards-compliant way to associate a specific script with
a specific part of your page - they're all global. Once they're all
loaded onto the page, they might as well be in the same script file.
-David
On Sep 20, 7:01 am, pbd22 <dush...@gmail. comwrote:
Hi.
I am wondering what do I replace the "this"
statement with to get the appropriate container/response.
When I try:
cal.prototype.d ates(cal.days[i].day);
I get
"this.cells has no properties"
Presumably, cal is a constructor function (and by convention should
start with a capital letter - Cal). The dates method likely uses the
this keyword expecting it to be a reference to an object constructed
from Cal, e.g.:
function Cal(){
// build a Cal object
}
Cal.prototype.d ates = function() {
// instructions for building a Cal object
}
// Create an instance of a Cal object
var aCalObject = new Cal(...);
// Call its dates method
aCalObject.date s(arg0);
When dates is called as a method of someCal, its this keyword is a
reference to aCalObject, which should have the required attributes as
a result of being constructed by Cal (that is up to you to ensure).
And, in the function declaration (within which lives 'dates'),
there is:
function MyCal()
{
this.cells = new Array();
...
The thing is (and this is key) I am calling
cal.prototype.d ates(cal.days[i].day) from a completely
different script (which references a different part of the
HTML on the page).
So you are calling cal.prototype.d ates directly, in which case its
this keyword will reference the prototype, but the property you are
looking for is likely higher up the scope chain and therefore out of
scope the way you are calling it.
How do I refer to the container of the
"this" in the "this.cells has no properties" error?
In that case, use the call method to pass the appropriate object to
the function:
cal.prototype.d ates.call(someO bj, cal.days[i].day);
Where someObj is the object that the dates this keyword should
reference. It should have the properties that the method expects it
to have.
--
Rob
On Sep 20, 9:24 am, RobG <rg...@iinet.ne t.auwrote:
[...]
Correcting a few typos...
Presumably, cal is a constructor function (and by convention should
start with a capital letter - Cal). The dates method likely uses the
this keyword expecting it to be a reference to an object constructed
from Cal, e.g.:
function Cal(){
// build a Cal object
Should be:
// instructions for building a Cal object
}
Cal.prototype.d ates = function() {
// instructions for building a Cal object
Should be:
// Specify the dates method
// the this keyword refers to the object
// that dates is called as a method of
}
--
Rob
David Golightly wrote:
[...] All script files in the same window (or frame) share the same
global namespace, aka the window object, regardless of where their
script tags are on the page.
posting = posting.replace (/window(\s+)obje ct/gi, "Global$1Object ");
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Stevens |
last post by:
Probably the wrong wording but since I'm not a scripter I won't claim
to know what I'm talking about.
I got this script from www.htmlgoodies.com
<script language="JavaScript">
<!--
window.open ('photos01.html','photogallery',config='height=550,
width=750,toolbar=no, menubar=no, scrollbars=no, resizable=no,
location=no, directories=no, status=no');
|
by: Hodad |
last post by:
I would like to adapt, as much as possible, the appearance and color red
of the
font in this button:
<P><CENTER><BUTTON VALUE="SUBMIT"><A
HREF="http://www.familytreedna.com/surname_join.asp?code=Q17978"
STYLE="TEXT-DECORATION: NONE;">
<FONT COLOR="RED" FACE="COPPERPLATE GOTHIC BOLD">Right
Here</FONT></A></BUTTON></CENTER></P>
|
by: Peter King |
last post by:
if you assign multiple classes in order to keep your classes generic
e.g
..classA { position.absolute; left:5 top:5 height:200 width:800 }
..classB { background-color: red}
..classC { background-color: green}
<div id="div1" class="classA classB" ...
but then want to dynamically assign a new class
|
by: aden |
last post by:
I have read the years-old threads on this topic, but I wanted to
confirm what they suggest. . .
Can the this pointer EVER point to a type different from the class that
contains the member function that the this pointer is being used in?
That is, is the type of the this pointer always determined entirely
syntactically (and never dynamically)?
Example: if a member function is invoked on an object of class Apple
(appleobj.drip_it() ),...
|
by: Daniel Ervi |
last post by:
Hi All,
I have a question for the group as I can't seem to come up with any
suitable solutions. I'm not that new to programming or C#, but
neither am I very fluent yet, so I'd appreciate any help at mastering
my craft.
What I am trying to do is best illustrated in code:
public class TBase
| |
by: Thomas H |
last post by:
Hi everyone, I've got a question that's more of a "style" question...
Do you guys reference "this" for every object that's inherited from
System.Web.UI.Page? For example, when you use the Session object, do you
say "this.Session.property" or do you just say "Session.property", and leave
off "this"?
I'm tending towards always using "this.Session" and "this.Response" and
"this.Label5.Text" - even though I don't have to. I have the...
|
by: relient |
last post by:
Question: Why can't you access a private inherited field from a base
class in a derived class? I have a *theory* of how this works, of
which, I'm not completely sure of but makes logical sense to me. So,
I'm here for an answer (more of a confirmation), hopefully.
First let me say that I know people keep saying; it doesn't work
because the member "is a private". I believe there's more to it than
just simply that...
Theory: You inherit,...
|
by: Alexander Dong Back Kim |
last post by:
Dear all,
I used to use C++ programming language at all time but moved to C# and
Java. Few days ago, I restarted studying about C++ with a very
beginner's mind. I wrote a simple class and gcc couldn't compile the
class. Any hints that I'm missing?
Header File:
#ifndef __Calc_h__
|
by: WaterWalk |
last post by:
Hello. The question about "deleting this inside the class's member
function" is discussed many times in this group and in the "C++
FAQs". But I still have two more questions.
1. Take the following class as an example:
class Test
{
public:
static void print_message(char *s) { printf("%s\n", s); }
void delete_me()
|
by: babakandme |
last post by:
Hi to every body...:D
I'm a novice C++ programmer & I've a question,
I have the ClassA & in it's constructor, I instantiate ClassB, and I
want send "this" pointer """pointer to ClassA""" to the ClassB.
But I get this Error from the compiler: and it's in ClassB...
Error from the compiler:
error C2061: syntax error : identifier 'TestA'
error C2143: syntax error : missing ';' before '*'
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
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...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |