Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widget fails to update original select element #840

Open
ghost opened this issue Mar 14, 2019 · 4 comments
Open

Widget fails to update original select element #840

ghost opened this issue Mar 14, 2019 · 4 comments

Comments

@ghost
Copy link

ghost commented Mar 14, 2019

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
Copy link
Collaborator

mlh758 commented Mar 14, 2019

What version of the widget are you using?

@ghost
Copy link
Author

ghost commented Mar 14, 2019

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
Copy link
Collaborator

mlh758 commented Jun 4, 2019

It seems like v3 already has this fix?

@ghost
Copy link
Author

ghost commented Jul 8, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant