0

I am trying to run a Jquery plugin QTip. The problem is that it is not running even though all the files are in the corect folders (plugin is both in info file and attched as a script below) and I took the code below from the plugin's website and pasted in the html section of WYSYWIG editor. Can anyone tell me why this is the case?

<script type="text/javascript" src="/sites/all/themes/bf/js/jquery.qtip.min.js"></script>
<script type="text/javascript">// <![CDATA[

// Create the tooltips only on document load
$(document).ready(function() 
 {
// By suppling no content attribute, the library uses each elements title attribute by default
 $('#content a[href]').qtip({
  // Simply use an HTML img tag within the HTML string
  content: 'dfdfdfdfdf'
   });
});
// ]]></script>
<div id="content">
<a href="dddf.html">Why this not working</a>
</div>
0

2 Answers 2

2

From the Drupal 7 upgrade guide:

Javascript should be made compatible with other libraries than jQuery by adding a small wrapper around your existing code:

(function ($) {   
      // Original JavaScript code. 
})(jQuery);

The $ global will no longer refer to the jquery object. However, with this construction, the local variable $ will refer to jquery, allowing your code to access jQuery through $ anyway, while the code will not conflict with other libraries that use the $ global.

(function ($) {
  // Create the tooltips only on document load
  $(document).ready(function() {
    // By suppling no content attribute, the library uses each elements title attribute by default
    $('#content a[href]').qtip({
      // Simply use an HTML img tag within the HTML string
      content: 'dfdfdfdfdf'
    });
  });
})(jQuery);
4
  • You can also change all the Dollar signs for "jQuery"
    – silkAdmin
    Commented Jul 14, 2011 at 4:57
  • Thanks, I added the wrapper but still not working..
    – Vonder
    Commented Jul 14, 2011 at 13:25
  • I'm leaning towards that its your WYSIWYG editor is the problem
    – iStryker
    Commented Jul 14, 2011 at 13:36
  • Can you check in firebug if either script loads?
    – iStryker
    Commented Jul 14, 2011 at 13:45
0

By default Drupal 7 uses jQuery 1.4.4. the Qtip2 ( I assume you are using the latest Qtip) has a requirement of jQuery 1.6 and up. http://qtip2.com/guides

Install the jquery-update module https://www.drupal.org/project/jquery_update and set the front-end to the required version level for Qtip and you should be ok.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.