jQuery: The Write Less, Do More JavaScript Library

Ticket #844 (closed bug: wontfix)

Opened 2 years ago

Last modified 3 months ago

Loading jQuery 1.1 with Prototype throws error

Reported by: dossy@… Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.4 Component: event
Version: 1.1.3 Keywords: prototype
Cc: Needs: Review

Description (last modified by john) (diff)

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)

Attachments

Change History

Changed 2 years ago by brandon

  • status changed from new to closed
  • resolution set to worksforme

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

Changed 1 year ago by aercolino

  • status changed from closed to reopened
  • resolution deleted

Changed 1 year ago by john

  • status changed from reopened to closed
  • description changed from 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) }}} to 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) }}}
  • version changed from 1.1 to 1.1.3
  • milestone set to 1.1.4
  • need set to Review
  • resolution set to worksforme

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

Changed 10 months ago by aercolino

  • status changed from closed to reopened
  • resolution deleted

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

Changed 9 months ago by davidserduke

  • status changed from reopened to closed
  • resolution set to worksforme

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

Changed 9 months 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.

Changed 6 months ago by fernborba

  • status changed from closed to reopened
  • resolution deleted

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...

Changed 6 months ago by brandon

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

Changed 4 months 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.

Changed 3 months ago by flesler

  • status changed from reopened to closed
  • resolution set to wontfix
  • component changed from core to event
  • milestone changed from 1.1.4 to 1.2.4

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.