I was using jQuery Update module, but it conflicts with Views and feature requests for library version per page or per theme are consistently killed. On the other side, Views maintainers seems to assume that if UI works with distribution's jQuery, it isn't broken. Long story short, I was forced to forget about jQuery Update the way we know it.
Solution I found is jQuery Multi module, as it allows load updated jQuery only, if there is a library that requires it in use on the page. And for things like Chosen (when jQuery Update is hacked out of requirements) it works great. Now, I have problem with javascripts directly attached to forms:
$form['#attached']['js'] = array(
drupal_get_path('module', 'aat_pc_product') . '/js/tag.js',
drupal_get_path('module', 'aat_pc_product') . '/js/tabs.js',
drupal_get_path('module', 'aat_pc_product') . '/js/categories.js',
);
jQuery Multi claims it can be used on any js file, but it's documentation says:
C) Put the JS anywhere else, like in a custom module, and use hook_jqmulti_files() to load it. No need to use the alias. 38
D) Put the JS anywhere, use the provided alias, and don't use the jqmulti hooks or UI. Simply load with drupal_add_js() or something similar. If you're only using this method, make sure to select the 'Load Always' checkbox in the jQuery Multi config.
Now, I can't do C) as I'm using Form API and I can't do D) as it breaks Views.
Form API for #attached
says:
Description: Allows loading of CSS, Javascript, libraries,
Converting my scripts to a libraries would help, as A) and B) options for jQuery Multi are for libraries, but only examples provided by Form API are for JS and CSS files.
There is one use-case for libraries provided:
$form['#attached']['library'][] = array('system', 'jquery.cookie');
but it's there without description.
I can make my scripts library:
function amymodule_library() {
$module_path = drupal_get_path('module', 'mymodule');
$items = array();
$items['mymodule_form'] = array(
'title' => t('My Module Form'),
'version' => '1.0.0',
'js' => array(
$module_path . '/js/tag.js' => array(),
$module_path . '/js/tabs.js' => array(),
$module_path . '/js/categories.js' => array(),
),
'css' => array(
$module_path . '/css/mymodule_form.css' => array(),
),
);
// dpr($items);
// die();
return $items;
}
And attach it as a library to a form:
$form['#attached']['library'] = array(
array('mymodule', 'mymodule_form'),
);
Sadly this does not make it appear on the configuration screen:
I know it's due to the first 2 methods described in documentation:
A) Put the JS in sites/all/libraries/ and use the UI at admin/config/system/jqmulti to select your library. All the library's JS files will be loaded with the jqmulti jQuery version. There is no need to use the alias in this case. This is ideal if you're using a prepackaged jQuery library or plugin.
B) Put the JS in sites/all/libraries/ and use hook_jqmulti_libraries() to include the library. No need to use the alias. This is ideal if you're using a prepackaged jQuery library or plugin, and is equivalent to method A.
Of course I cannot put my scripts there, they are built in part of my module.
Now, I'm perfectly open to module hacking, if that's what needed, but if there is a way to "pretend" that my module's library is in the folder jQuery Multi wants it to be, I would be grateful to know it.