Export to GitHub

ufd - issue #5

Issues playing nice with prototype


Posted on Jan 26, 2010 by Grumpy Bear

I have an existing site that is using prototype that I am trying to add UFD to. I have made the jQuery.noConflict(); change by adding jQuery.noConflict(); as the first line in jQuery.ui.ufd.js and doing a find / replace for $ with jQuery in that file as well.

As soon as i remove my prototype ref, everything works as expected.

I am using prototype version 1.6.1_rc3.

This is the order that I'm loading scripts. <script src="/javascripts/prototype.js" type="text/javascript"></script> <script src="/javascripts/effects.js" type="text/javascript"></script> <script src="/javascripts/controls.js" type="text/javascript"></script>

<script src="/javascripts/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="/javascripts/ui.core.js" type="text/javascript"></script> <script src="/javascripts/jquery.bgiframe.min.js" type="text/javascript"></script> <script src="/javascripts/ufd/jquery.ui.ufd.js" type="text/javascript"></script>

Comment #1

Posted on Feb 3, 2010 by Massive Ox

You shouldn't need to do any changes for this plugin; it is jQuery.noConflict() compatible. The whole plugin is wrapped inside a function scope using jQuery anonymouse function invoked immediately:

(function($){ // plugin code: // code refers to "$", which is declared and passed in above

})(jQuery) //invoke this anonymous function immediately, passing in (global) jQuery

So the $ used internally is not actually the global one.

You need to ensure that noConflict is called before any of your prototype code executes, and definitely outside the plugin closure.

[http://api.jquery.com/jQuery.noConflict/] See [http://docs.jquery.com/Plugins/Authoring#Custom_Alias_in_plugin_code]

Comment #2

Posted on Feb 3, 2010 by Massive Ox

Comment deleted

Comment #3

Posted on Feb 3, 2010 by Massive Ox

(No comment was entered for this change.)

Status: Invalid

Labels:
Type-Defect Priority-Medium