I have been using the JQP module to load jQuery plugins (like jQuery UI, jQuery JSON). After upgrading to 6.x-2.0-beta1, I can't seem to get it working anymore.

I have created the "sites/all/js_library" directory and put the files in there, for example, a "jquery.ui-1.7.1" sub-folder contains all the jQuery UI stuff. Then I created a ".info" file in the "sites/all/js_library" folder with these:

name = JQuery UI
description = Files from jQuery UI and jQurey JSON libraries.
project_url = http://ui.jquery.com

scripts[][] = jquery-ui.js
stylesheets[][] = jquery-ui.css

scripts[1.7.1][] = jquery-ui[-1.7.1].custom.js
stylesheets[1.7.1][] = jquery-ui[-1.7.1].custom.css

scripts[][] = jquery-json.js

But I still can't load the libraries. Here is how I try to do that:

	drupal_add_js_library('jquery-ui', 0, array
			      (
			       'css'	=> 'jquery-ui.css',
			       'js'	=> 'jquery-ui.js'
			      )
			     );
	drupal_add_js_library('jquery-json', 0, array
			      (
			       'js'	=> 'jquery-json.js'
			      )
			     );

I don't see my stuff in the "sites/all/js_libraries" showing up in the JQP admin page either, which I think indicates that the ".info" file is not working. I am trying to follow the code but would really appreciate any insights from others.

Thanks and regards,
--
Wei

Comments

ww9rivers’s picture

Got it figured out.

  1. The .info file is split into jquery.json.info and jquery.ui.info -- files named to start with a dot are not loaded.
    name = jquery.json
    description = Files from jQurey JSON library.
    project_url = http://code.google.com/p/jquery-json/
    
    scripts[][] = jquery-json.js
    
    scripts[1.3][] = jquery.json-1.3.min.js
    
    name = jquery.ui
    description = Files from jQuery UI libraries.
    project_url = http://ui.jquery.com
    
    scripts[][] = jquery-ui.js
    stylesheets[][] = css/jquery-ui.css
    
    scripts[1.7.1][] = jquery-ui-1.7.1.custom.js
    stylesheets[1.7.1][] = css/smoothness/jquery-ui-1.7.1.custom.css
    

    Note that the .info file name must be the same as the name field inside the file. I had trouble when I had name = jquery-json when the file name is jquery.json.info, in which case the JQP status page would show the library name as jquery-json but the internal data structure uses jquery.json as the name (key) for that library.

  2. When loading the libraries, simply do this:
    	drupal_add_js_library('jquery.ui');
    	drupal_add_js_library('jquery.json');
    
uziben’s picture

I like to get your module and to know more about how to use it in Drupal

regards
uziben1@gmail.com

ww9rivers’s picture

I am not sure if you are still interested, I have written a blog entry here about what I have used:

http://teknowfile.blogspot.com/2009/08/drupal-6-jqp-jquery-plugins.html