Hi all,

The following problem occurs, when using the following code the ajax call fires:

$arr['analytes'] = array(
	'#type' => 'select',
	'#multiple' => TRUE,
	'#title' => t('Analytes'),
	'#options' => $analytes,
	'#ajax' => array(
		'callback' => 'ajax_reporting_report_callback',
		'wrapper' => 'report-div',
		'method' => 'replace',
		'effect' => 'fade',
	),
);

but when changing it to this:

$arr['analytes'] = array(
	'#type' => 'multiselect',
	'#title' => t('Analytes'),
	'#options' => $analytes,
	'#ajax' => array(
		'callback' => 'ajax_reporting_report_callback',
		'wrapper' => 'report-div',
		'method' => 'replace',
		'effect' => 'fade',
	),
);

It doesn't. Did I miss something??

CommentFileSizeAuthor
#3 ajax_multiselect.zip1.88 KBjbeuckm

Comments

jbeuckm’s picture

I have been looking for a solution to this for a while. For a workaround, you can add an invisible select element after your multiselect. Add your ajax processing to the dummy select. Then attach a javascript behavior to your multiselect that triggers "change" on the dummy multiselect.

I'm working through adding the behavior at the moment. I'm going to replace my this.trigger('change') line with one that changes the dummy select.

      $.fn.oldAddOption = $.fn.addOption;
      $.fn.addOption = function(arguments) {
        this.oldAddOption(arguments);

        this.trigger('change');
      }
jbeuckm’s picture

Line 102 of multiselect.module has the #ajax property commented out.

jbeuckm’s picture

StatusFileSize
new1.88 KB

Here is a module that enables #ajax for the multiselect element. Just add a normal #ajax property to the element in your form builder function. This module creates a hidden 'select' element with the ajax handler and triggers a 'change' event when your multiselect items are moved around.

mparker17’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

multiselect-7.x-1.9 is no longer supported, because Drupal 7 is no longer supported.

Can you confirm if this is still an issue in multiselect-2.0.0-beta4?

I'm going to mark this issue as "Postponed (maintainer needs more info)"... but when you answer, please change it back to "Active". If there is no reply in ~6 months, then I will mark this issue as "Closed (outdated)". Thank you in advance for your understanding and patience as I try to keep this module's issue queue clear.