hello,

i would like to know how to include jqueryui in every user role, because i think that currently only admin role has jqueryui..

thanks!

Comments

heck’s picture

does anyone have any idea on this matter?

Anonymous’s picture

Are you sure you don't have a module enabled that's causing this behaviour? The jquery ui components are added by modules that specifically need them, and I guess those modules would make access decisions.

I have a few D7 sites making large use of jquery ui and I haven't had to set any permissions for any of them, they just work for every visitor.

heck’s picture

Nope. The problem is, I am the one who declares the need for the jqueryui instance (not by using the drupal function), not my module.

Anonymous’s picture

Sorry that doesn't make sense to me, exactly how are you including jquery ui if you are not using the drupal function and not doing it in a module???

heck’s picture

Sorry, let me rephrase my query here...

I need to have jQuery UI included in every page request (or at least have some rules).

Thanks!

Anonymous’s picture

Do you know if it's just the core UI JS you need or a specific component for every page? If you need the autocomplete component for example you can use something like this in a module file:

function MYMODULE_init() {
  drupal_add_library('system', 'ui.autocomplete');
}

Since the base 'ui' component is a dependency of 'ui.autocomplete' that library will be automatically included

Does that help?

heck’s picture

Is there such thing as just "ui", like this?

function MYMODULE_init() {
  drupal_add_library('system', 'ui');
}
Anonymous’s picture

Yep, you can find a full list of them in the system_library() function: http://api.drupal.org/api/drupal/modules--system--system.module/function...

heck’s picture

Thank you very much! =)

I assume this will fix my problem in placing jqeryui in every page..

heck’s picture

Unfortunately, I still can't include jQuery UI in all of my pages (when I'm logged out)

Anonymous’s picture

I've just checked and confirmed that the following code will 100% definitely include jQuery UI (in my case found at misc/ui/jquery.ui.core.min.js?v=1.8.7) on every page, regardless of whether a user is logged in or not. If it doesn't work then you must have another module installed that's stopping that particular file being included when a user is not logged in. Just to clarify, drupal_add_library does no user access checking so can't possibly fail to add the javascript if it's called in hook_init().

function MYMODULE_init() {
  drupal_add_library('system', 'ui');
}

Hope that helps

Tony Finlay’s picture

Where on my site do I put this code? I want the UI to load on every page as I am utilising it in a sitewide block as well as nodes

Thanks

Anonymous’s picture

In a custom module, in a hook_init() function

Tony Finlay’s picture

Absolutely no idea how to do this and no time to learn yet as i'm in the middle of a production website

murz’s picture

Also you can add this code to some function in template.php file of current theme (if you want to load JQuery UI for all pages), for example in function phptemplate_preprocess_html() or function phptemplate_process_page.

yuseferi’s picture

i test this but not working for me,
to add library you need to sepecify which library you want to add like this

function yourmodule_init(){
	drupal_add_library('system', 'ui.draggable');
	drupal_add_library('system', 'ui.sortable');
}

I have be born to be mankind

quotientix’s picture

Old thread, but maybe this helps: you can also just paste the code in the preprocess_html function of your template.php

drupal_add_library('system', 'ui');
rajatgusain’s picture

In the third argument if you will pass "$every_page = TRUE" then it will be included for all the pages.

drupal_add_library('system', 'ui.sortable', $every_page = TRUE).

For more details : https://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_...