On Wed, 11 Oct 2006 12:35:42 +0200, Fabio Forno <[EMAIL PROTECTED]> wrote:
Hi, I've a problem with an athena widget and IE.
I define a widget for a LiveFragment like this one:
var Widgets = {};
Using a recent version of Nevow, you shouldn't need to define the Widgets
namespace explicitly. Also, "Widgets" is a pretty vague name. I'd suggest
picking something less likely to collide.
Widgets.ChatWidget = Nevow.Athena.Widget.subclass('Widgets.ChatWidget');
Widgets.ChatWidget.methods(
function keyPressed (self, event) {
if(event.key()["string"] == "KEY_ENTER") {
text_area = window.document.getElementById("chat_area");
d = self.callRemote('got_text', text_area.value);
d.addCallback(self.text_sent);
}
}
)
It's better to not use getElementById. Instead, make the chat area node
a child of the ChatWidget's node and find it either by class or using the
new Widget.nodeById method.
Then in the xml template I try to get a reference to the just defined
method in this way:
widget = Nevow.Athena.Widget.get(
document.getElementById("athena:1");
);
widget.keyPressed
Likewise, "athena:1" is an implementation detail, and you can't rely on
your widget getting id "1" all the time. Instead, try using the
athena:handler feature:
<div nevow:render="liveFragment">
...
<textarea>
<athena:handler event="onkeypress" handler="keyPressed" />
</textarea>
</div>
In firefox everything is ok, while in explorer 6.0 I get undefined.
MOreover, in i.e. there is this oddity. if a loop on all the
attributes of widgetwith for(var i in widget) , I get also the
keyPressed method, but when I try to get it with widget[i], I keep
having undefined as result.
Any idea?
A difference here wouldn't surprise me. Iteration in JavaScript is extremely
inconsistent, even within a single runtime. I don't know of the /specific/
problem which causes the behavior you're describing above, and it may be
fixable, but it'd probably be better just to not rely on iteration.
Jean-Paul
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web