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

Add new method 'removeOption' #158

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add new method 'removeOption' #158

wants to merge 3 commits into from

Conversation

moregeek
Copy link
Contributor

  • Added a new method to dynamically remove options form the multi-select.
  • Added Tests for the new method 'removeOption'.
  • Added Tests for the existing method 'addOption'.
  • Added documentaion patch to apply on the html files on loudev.com

@soWizardly
Copy link

soWizardly commented Jul 21, 2016

I actually copy/pasted this into my project, and after some testing...it appears that an adjustment needs to be made for this to work properly.

'removeOption' : function(options){
  var that = this;

  if (options.value) options = [options];
  $.each(options, function(index, option){

    // Option value needs to be passed through that.sanitize first.
    option.id = that.sanitize(option.value);

    if (option.value && that.$element.find("option[value='"+option.value+"']").length === 1){
      that.$element.find("option[value='" + option.value + "']").remove();

      // and now the below works properly...
      that.$container.find("ul.ms-list [id^='" + option.id + "']").remove();
    }
  })
 },

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

Successfully merging this pull request may close these issues.

2 participants