Posted by Emerya.thomas on December 3, 2012 at 4:54pm
Version Drupal 7.16
I'm trying to use draggable of jquery in Drupal way :
I have a simple page (with hook_menu) wich call an js and render a simple div with the good class to draggable :
<?php
(function($) {
Drupal.behaviors.testJs = {
attach : function(context, settings) {
$('.test-js').draggable();
});
}
}
})(jQuery);
?>This js is load.
I add library of jquery Drupal :
<?php
drupal_add_library('system', 'ui');
?>or
<?php
drupal_add_library('system', 'ui.draggable');
?>But nothing happen....
When I had an external jquery like :
<?php
drupal_add_js('http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js', 'external')
?>draggable work.
I try to enable jquerry update module, but nothing more....
Comments
Read
Read http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_add_library/7
Your code should be like:
<?phpdrupal_add_library('your_module', 'your_js_file');
?>
Actually they are using
Actually they are using drupal_add_library() correctly, it is meant to load libraries defined by other modules as well as your own.
You shouldn't be adding
You shouldn't be adding jquery, as Drupal includes it as a part of core. Including it in your system causes hard-to-debug bugs.
Jaypan We build websites