0

I am using the jQuery multiselect widget on another non-Drupal project and I would love to be able to use it with CCK in Drupal 7. I have found this module for CCK multiselect but it is not exactly what I want. I realize I could try to write something, but I was curious if anyone has used the above with Drupal before or if there is a module out there I'm missing.

4 Answers 4

3

Not quite what you are requesting but thinking that chosen might be a good alternative to what your searching for.

1
  • I think this is the best solution in most cases Apr 24, 2012 at 15:42
3

Here you are: jQuery UI MultiSelect Widget

1
  • awesome. this didn't exist when I started this thread
    – hross
    Jun 13, 2013 at 18:38
1

Since this is Drupal 7 isn't it easier just adding the .js files to your theme's js folder and adding this in your info file?

scripts[] = path/to/js/jquery.multiselect.min.js
0

Add the jquery.multiselect.js and jquery.multiselect.css files to your theme folder, such as /sites/all/themes/your-theme/js/jquery-multiselect/

Then add this to your template.php

drupal_add_js(path_to_theme().'/js/jquery-multiselect/jquery.multiselect.min.js');
drupal_add_css(path_to_theme().'/js/jquery-multiselect/jquery.multiselect.css');
drupal_add_js('$(document).ready(function(){$("#example").multiselect();});', array('type' => 'inline', 'scope' => 'footer', 'weight' => 6));

And to make it only show up on certain nodes types, you can use a preprocess node hook in your template.php:

function your_theme_preprocess_node(&$variables) {
  if ($node->type == 'my_content_type') {
    drupal_add_js(path_to_theme().'/js/jquery-multiselect/jquery.multiselect.min.js');
    drupal_add_css(path_to_theme().'/js/jquery-multiselect/jquery.multiselect.css');
    drupal_add_js('$(document).ready(function(){$("#example").multiselect();});', array('type' => 'inline', 'scope' => 'footer', 'weight' => 6));
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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