Ruby on Rails Saturday, December 31, 2011

Friday, December 30, 2011, 7:09:08 PM, you wrote:

CW> On Fri, 2011-12-30 at 12:21 -0700, Ralph Shnelvar wrote:
>> I have a library conflict between jQuery.js & accordion.js
>>
>> The first line of accordion.js is
>>
>> $(document).ready(function() {
>>
>>
>> Firebug displays
>> $(document).ready is not a function
>>
>>
>> I have read http://docs.jquery.com/Using_jQuery_with_Other_Libraries. This link is an explanation of how to resolve the conflict.
>>
>>
>>
>> To that end I have in a partial haml file
>>
>> (function($) {
>> = javascript_include_tag 'accordion.js'
>> })(jQuery);
>>
>>
>> The rendered output is
>> (function($) {
>> <script src="/assets/accordion.js?body=1" type="text/javascript"></script>
>> })(jQuery);
>>
>>
>>
>> but I am still getting the
>> $(document).ready is not a function
>> error message.
>>
>>
>>
>> Is what I am trying to do even legal?
CW> ----
CW> sounds as if you tinkered with application.js or removed the reference
CW> to it completely and thus jquery isn't loaded at all.

Craig:

I modified accordion.js by wrapping it in
(function($) { ... })(jQuery);

And everything works.


If I don't do it, the text
(function($) {
})(jQuery);
ends up being displayed on the webpage as the 1st two lines. I didn't see it before.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment