Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 8 years ago

#844 closed bug (wontfix)

Loading jQuery 1.1 with Prototype throws error

Reported by: dossy@… Owned by:
Priority: major Milestone: 1.2.4
Component: event Version: 1.1.3
Keywords: prototype Cc:
Blocked by: Blocking:

Description (last modified by john)

Loading jQuery 1.1 with Prototype on Firefox 1.5.0.9 results in this error:

this.bind is not a function
  return f ? this.bind(o, f) : this.trigger(o);
jquery.js (line 1418)

Change History (10)

comment:1 Changed 13 years ago by brandon

Resolution: worksforme
Status: newclosed

This works for me. Please feel free to reopen the ticket with a more detailed test case.

comment:2 Changed 13 years ago by aercolino

Resolution: worksforme
Status: closedreopened

comment:3 Changed 12 years ago by john

Description: modified (diff)
Milestone: 1.1.4
need: Review
Resolution: worksforme
Status: reopenedclosed
Version: 1.11.1.3

This works fine. Please don't re-open the bug unless you have something to back up the claim.

comment:4 Changed 12 years ago by aercolino

Resolution: worksforme
Status: closedreopened

This problem is still unresolved (jQuery 1.2.1).

Here is how you can reproduce the error.

1- install the bookmarklet jQuerify into your FireFox browser

2- go to http://www.google.com, jQuerify it, and at the FireBug console run the following command

jQuery( 'body' ).bind( 'click', function() { alert( 'Hi' ) } )

3- click on the page and you'll see the alert

4- go to http://developer.mozilla.org/, jQuerify it, and at the FireBug console run the previous command

comment:5 Changed 12 years ago by davidserduke

Resolution: worksforme
Status: reopenedclosed

jQuerify isn't exactly the best way to load jQuery. Plus to get jQuery to work with Prototype you must use .noConflict() after jQuery is loaded (which jQuerify does not do). When I tried jQuerify with the Mozilla site I started getting lots of Prototype errors.

Next time you open the bug please do so with your own single html page which shows the conflict and please read the documentation on what is necessary for it to work.

http://docs.jquery.com/Core/jQuery.noConflict

comment:6 Changed 12 years ago by aercolino

I started getting lots of Prototype errors

That's very strange, because I cannot see any error at all... I'm using last version of FF2, with Firebug, and my jQueryfy bookmarklet is

javascript:var%20s=document.createElement('script');s.setAttribute('src',%20'http://jquery.com/src/jquery-latest.js');document.body.appendChild(s);s.onload=function(){jQuery.noConflict()};void(s);

As you see jQuery.noConflict() is in place :-), and $ and jQuery are different things on the Mozilla site, after jQueryfying it. Anyway, this is a different issue, I think.

This bug is annoying because it makes my HotChili plugin useless for the Mozilla site! And there is a lot of code there that I'd like to see highlighted.

comment:7 Changed 12 years ago by fernborba

Resolution: worksforme
Status: closedreopened

Hello,

The same error is happening with me. Above you can see the HEAD of the page:

<script type="text/javascript" src="/Data/AJAX/Rico/Prototype.js"></script>
<script type="text/javascript" src="/Data/AJAX/Rico/AJAX.js"></script>
<script type="text/javascript" src="/Data/AJAX/Ara.js"></script>

<script src="lib/jquery-1.2.1.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/jquery.dimensions.js" type="text/javascript" charset="utf-8"></script>
<script src="lib/jquery.accordion.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    <!--
	var $j = jQuery.noConflict();
    $j(function () {
        $j('ul.drawers').accordion({
            header: 'div.drawer-handle',
            selectedClass: 'open',
            event: 'mouseover'
        });
    });
    //-->    
</script>

And the firefox 2.0.0.11 gives me this error:

Error: this.bind is not a function
Source File: http://localhost/NewPage/lib/jquery-1.2.1.js
Line: 1984

If there's a answer for that I'm sorry but I'vent saw it yet...

comment:8 Changed 12 years ago by brandon

This seems to be caused by Prototype extending the Function.prototype to include a bind method.

comment:9 Changed 12 years ago by mtrimpe

We also just ran into the problem and it's caused by namespace clashes on Object.extend and Function.bind.

Because we're on a deadline here; we implemented a slightly less than elegant workaround.

The solution was to rename both the Function's bind method and the Object's extend method in PrototypeJS to something else (e.g. prototypeBind and prototypeExtend). When you do this throughout the Prototype library and for any references in your local code jQuery once again works like a charm.

comment:10 Changed 12 years ago by flesler

Component: coreevent
Milestone: 1.1.41.2.4
Resolution: wontfix
Status: reopenedclosed

This doesn't seem like something that can (has to be) fixed by jQuery. Once Prototype avoids clashing the global namespace, this will cease (maybe they did already).

I'll close this for now.

Note: See TracTickets for help on using tickets.