[Rails-spinoffs] Re: problem with xul/prototype experiment: "bind" method not found

Steve Conover sconover at gmail.com
Mon Jan 30 15:38:00 GMT 2006


Attached is my inital go at making prototype safe in XUL.  If anyone
has any followup questions or (later on) wants to get ahold of my latest
prototype.js for XUL, email me.

What I've done to get prototype to work is change bind from a
prototype method to a freestanding function that takes the necessary
params.  Decidedly unsexy, but it works (so far).

Regards,
Steve

On 1/29/06, Steve Conover <sconover at gmail.com> wrote:
> Just for the record, I figured out the problem.  There is a bug in the
> XUL JS engine (going WAY back) that prevents methods from being added
> dynamically to Function or RegExp.  Apparently other classes should be
> ok.
>
> References:
>
> http://groups.google.com/group/netscape.public.mozilla.jseng/browse_thread/thread/333a37784e94bfb1/a11efcdd083031e2?lnk=st&q=xul+function+prototype+group%3Anetscape.*&rnum=3&hl=en#a11efcdd083031e2
>
> http://groups.google.com/group/netscape.public.mozilla.jseng/browse_thread/thread/89864da5f416b06a/5ca35cfd850cc006?lnk=st&q=xul+function+prototype+group%3Anetscape.*&rnum=1&hl=en#5ca35cfd850cc006
>
> The bug:
>
> https://bugzilla.mozilla.org/show_bug.cgi?id=300079
>
>
> Which means I'll probably be making my own XUL-friendly prototype.js...fun.
>
> -Steve
>
> On 1/28/06, Steve Conover <sconover at gmail.com> wrote:
> > Hi everyone,
> >
> > I was playing around with xul + prototype, and everything seemed to be
> > going well until I ran into a wall - there seems to be some problem I
> > can't explain with Function.prototype.bind, for instance when I run
> > this code:
> >
> >                try {
> >                         new Ajax.Request("http://localhost:3000/search/hello", {
> >                                 onComplete: this.onHelloComplete.bind(this)
> >                         });
> >                 } catch (e) {
> >                         alert(e);
> >                 }
> >
> > I get an exception printed that says "TypeError:
> > this.onHelloComplete.bind is not a function".  I've done some more
> > experimenting and confirmed that my functions just don't have bind
> > methods.
> >
> > I'm a little fuzzy on the more advanced aspects of javascript like
> > this: can someone more knowledgable please give me a brief explanation
> > about why "bind" works?  In other words, how is it that
> > Function.prototype.bind is available on every function object?  I
> > can't get my head wrapped around the "bind" implementation...
> >
> > And if anyone has more direct ideas on what the problem could be (why
> > it's not working in the xul environment specifically), I'd love to
> > hear them.
> >
> > Thanks,
> > Steve
> >
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: prototype_for_xul.zip
Type: application/zip
Size: 10968 bytes
Desc: not available
Url : http://wrath.rubyonrails.org/pipermail/rails-spinoffs/attachments/20060130/71b74d73/prototype_for_xul-0001.zip


More information about the Rails-spinoffs mailing list