Skip to Content Skip to Menu

[SOLVED] Possible Jquery conflict

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
10 years 5 months ago - 10 years 5 months ago #245435 by dotcom22
[SOLVED] Possible Jquery conflict was created by dotcom22
hello

I would like create a simple Jquery slideshow for slide several custom image (not avatar) in CB profile. For do that I found this little script:

jonraasch.com/blog/a-simple-jquery-slideshow

So I installed the script by putting the Jquery code with auto-action and trigger onAfterUserProfileDisplay but the slideshow don't work. I tried also to paste the code directly in my index.php template file just before </head> tag without more success.

I don't know why I can use this script because CB already include Jquery in profile page (trough url www.mysite.com/components/com_comprofiler/js/jquery-1.5.2/jquery-1.5.2.min.js?v=d076a38b6bb73153 ) so is normally not necessary to include again the library in the page. It seem not a Jquery version problem because the script use the version 1.2 and CB use version 1.5.2.

Then if I paste the url of Jquery such <script type="text/javascript" src=" www.mysite.com/components/com_comprofiler/js/jquery-1.5.2/jquery-1.5.2.min.js?v=d076a38b6bb73153 "> just before the slideshow, all work well even if in that case the Jquery library are called 2 time in the page (one time by CB and one time because I pasted the url in template file).

any clue ?

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 10 years 5 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 5 months ago #245461 by krileon
Replied by krileon on topic Possible Jquery conflict
CBs jQuery can't conflict. It's in no conflict mode and namespaced. Press F12 in Chrome or Firefox and review the Console tab while using your jQuery to see what maybe causing it to break. Also note CB already handles document ready so the one in that jQuery is redundant. That jQuery is also needlessly defining its function in global namespace for some reason, which should just be an anonymous function of the setInterval.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
10 years 5 months ago - 10 years 5 months ago #245475 by dotcom22
Replied by dotcom22 on topic Possible Jquery conflict
I don't see something special in the console.. However maybe I'm not able to look correctly. I know use the console for inspect css but for script is another story.

However maybe the problem is finally related to version because if I don't include the link who point to Jquery library the slideshow don't work and if I include

<script src=" code.jquery.com/jquery-1.7.1.min.js ">

in my template file, the slideshow work.

So 3 questions:

- Is possible to update the library used by CB with a version more higher ?

- Why CB don't use hosted library such the one available on Jquery.com or Google ? If I'm not wrong this allow also to reduce page load for better seo.

- I'm totally unclear about how Jquery is supposed to be used in Joomla and all third party addons. Actually I'm under Joomla 3.2 and I plan to update to 3.3. For what I know, Joomla use already Jquery and the version 3.3 has been advertised to be more powerful with it. So I wondering why Joomla do not use (maybe is already the case) Jquery in the whole site for avoid for all others addons (included CB) to declare again Jquery in their code whit possible conflict or inconsistencies. A version problem ??

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 10 years 5 months ago by dotcom22.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 5 months ago #245516 by krileon
Replied by krileon on topic Possible Jquery conflict

- Is possible to update the library used by CB with a version more higher ?

No, CB 2.0 will be using latest jQuery though.

- Why CB don't use hosted library such the one available on Jquery.com or Google ? If I'm not wrong this allow also to reduce page load for better seo.

Because CDNs create a dependency on an external server. This would be an absolute nightmare if the majority of the web used CDN as you're dependent on that servers up time, reliability, and speed. Using our own library also guarantees compatibility with all of the jQuery plugins we provide. What's worse is if the CDN was compromised or suddenly decided to add tracking code they could because it's just a JS header file, which you could execute whatever JS they wanted. A lot of CDNs are also blocked in various countries so your side probably won't work for some countries. In short I'm pretty against CDNs.

- I'm totally unclear about how Jquery is supposed to be used in Joomla and all third party addons. Actually I'm under Joomla 3.2 and I plan to update to 3.3. For what I know, Joomla use already Jquery and the version 3.3 has been advertised to be more powerful with it. So I wondering why Joomla do not use (maybe is already the case) Jquery in the whole site for avoid for all others addons (included CB) to declare again Jquery in their code whit possible conflict or inconsistencies. A version problem ??

You're not having a jQuery conflict. That jQuery just isn't written very well. It's using a global namespace function for no reason, which won't work when declared through CB because we auto add document ready which a global function won't work in.

The below is the final function on the site you linked, but without a global namespaced function. This may work in CB Auto Actions as Code with the jQuery method, but I've no idea as I didn't test it nor can I guarantee any form of functionality for jQuery I didn't created.

Code:
setInterval( function() { var $active = $('#slideshow IMG.active'); if ( $active.length == 0 ) $active = $('#slideshow IMG:last'); var $next = $active.next().length ? $active.next() : $('#slideshow IMG:first'); $active.addClass('last-active'); $next.css({opacity: 0.0}) .addClass('active') .animate({opacity: 1.0}, 1000, function() { $active.removeClass('active last-active'); }); }, 5000 );


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
10 years 5 months ago #245527 by dotcom22
Replied by dotcom22 on topic Possible Jquery conflict
Ok thank for clarification. I think you right about cdn and is better to have our own library file hosted on our side.

So in my case I was able finally to make working a great responsive slideshow: responsiveslides.com

Then one I mentioned previously was not adapted because the responsive mode was a bit buggy.

So using auto-action "Code" with "Header" method, I placed the Jquery link and the code which invoke the plugin. This because the slideshow need to use at least Jquery 1.6 for work.

Now I wondering if the fact to have 2 Jquery link (the one used by cb and the one used by this slideshow) inside the same page could be a problem or not. For what I see, all seem to be fine but I would like to be sure.

thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum