ehynds / jquery-ui-multiselect-widget

jQuery UI MultiSelect widget
GNU General Public License v2.0
1.37k stars 692 forks source link

Widget fails to update original select element #840

Open ghost opened 5 years ago

ghost commented 5 years ago

What is the current behavior?

The original select element is not updated with the user's checking and unchecking

What is the expected behavior?

I click a checkbox in the multiselect and the original select is updated. If I click the checkbox Main then the original select option Main is updated as selected.

mlh758 commented 5 years ago

What version of the widget are you using?

ghost commented 5 years ago

version 2.0.1

but I modified it and added these 2 functions

resync : function() { var $inputs = this.$inputs; var $options = this.element.find('option'); if ($inputs.length === $options.length) { var inputValues = {}; $inputs.each( function() { inputValues[this.value] = this;
}); $options.each( function() { if (this.value in inputValues) { inputValues[this.value].checked = this.selected; } }); this._trigger('resync'); this.update(); } else { this.refresh(); } }, val: function(newValue) { if (typeof newValue !== 'undefined') { this.element.val(newValue); this.resync(); return this.element; } return this.element.val(); },

And I added this line in the _makeOption

  // Icon images for each item.
  var optionImageSrc = option.getAttribute('data-image-src');
  if (optionImageSrc) {
    var img = document.createElement('img');
    img.setAttribute('src', optionImageSrc);
    span.insertBefore(img, span.firstChild);
  }
mlh758 commented 5 years ago

It seems like v3 already has this fix?

ghost commented 5 years ago

I'm using Version 2. I can't use Version 3 it doesn't work with the program and breaks the whole program.

On Tue, Jun 4, 2019 at 5:41 PM Michael notifications@github.com wrote:

It seems like v3 already has this fix?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ehynds/jquery-ui-multiselect-widget/issues/840?email_source=notifications&email_token=AD37CF3KMOA3NCGXD3JVGW3PY3OPJA5CNFSM4G6KAH42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODW56SWA#issuecomment-498854232, or mute the thread https://github.com/notifications/unsubscribe-auth/AD37CF27SKL6KYQT3LQYXKLPY3OPJANCNFSM4G6KAH4Q .