Page 1 of 1
Javascript .watch() method.
Posted: Wed Jul 25, 2007 8:19 pm
by JellyFish
I'm having trouble getting this method to work. I tried testing it on an Untitled page in Firebug and it simple doesn't work.
Code: Select all
obj.watch("prop", function () {
alert(this.prop);
});
And so when I change the obj.prop's value the function doesn't run and there's no alert message. Whaaaa!
Am I messing something?
Posted: Wed Jul 25, 2007 8:25 pm
by superdezign
Try alerting a regular string like "working." It may be a problem with your use of this.
Posted: Wed Jul 25, 2007 9:36 pm
by JellyFish
superdezign wrote:Try alerting a regular string like "working." It may be a problem with your use of this.
Nah. That didn't work. Maybe it's a firebug bug?
Posted: Wed Jul 25, 2007 9:50 pm
by superdezign
JellyFish wrote:Nah. That didn't work. Maybe it's a firebug bug?
That wouldn't make sense. That would imply that it worked in IE and not in FF.
I've never used the watch method before, so I doubt I'll be too much help on it... Simple alerts seem to work fine enough.
Posted: Wed Jul 25, 2007 10:03 pm
by JellyFish
Yeah. Well I know that it should work. After all the watch method was described in MDC javascript documentation.
I just don't get it. This would be an awesome method to use to build a library. Don't you think?
Posted: Wed Jul 25, 2007 10:11 pm
by JellyFish
Hey I got it working. It just didn't work with firebug. I tested the code at
http://htmledit.squarefree.com. Woot!
But it doesn't appear to work in IE.

Damn you lazy, no good, son of a... MICROSOFT!
Posted: Thu Jul 26, 2007 6:34 am
by VladSun
Yes - firebug doesn't allow calls to alert() at all. Whenerver you call an alert() firebug throws an exception. I don't know why ...
Posted: Sun Jul 29, 2007 4:24 pm
by smudge
@VladSun: I've noticed that too, but only in some cases. Sometimes I'll try to alert() something, and FB just sits there, but 5 min later, I try alert("Hello") and it alerts it.
Posted: Mon Jul 30, 2007 5:59 am
by VladSun
@smudge: I am not sure that firebug "fires this bug"

at every usage of alert. But having a 99% possibility of this happening, it is safer to turn off firebug when there are calls to alert().
Posted: Mon Jul 30, 2007 8:02 am
by superdezign
I am really not seeing this error at all. I've never run into a problem with my scripts and Firebug...
Posted: Mon Jul 30, 2007 10:00 am
by VladSun
Well, I've seen it too often. Maybe it depends on the software ... I am using:
Windows XP SP2
Mozilla/5.0 (Windows; U; Windows NT 5.1; bg; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5
FireBug 1.05
And it is for sure that calling alert() causes Firebug to throw an exception (maybe not every time) - I jsimply add/remove alert("OK") line and the results are different when usiing Firebug.
Posted: Mon Jul 30, 2007 11:30 pm
by JellyFish
Alerts work fine in firebug for me. Except in this case.