yanickrochon / jquery.uix.multiselect

Completely rewritten, multiselect widget with a more concise API
http://mind2soft.com/labs/jquery/multiselect/
MIT License
139 stars 62 forks source link

.remove() method used for option thows a null reference exception #72

Open thirumalaicb opened 11 years ago

thirumalaicb commented 11 years ago

Hi,

I am using your multiselect control. I find an issue when I do the below steps. This issue is there in the demo page as well.

http://mind2soft.com/labs/jquery/multiselect/optionvalues.html

Steps to repro:

  1. Let all the items be in the available side.
  2. Click on any item and it gets selected and displayed in the selected side.
  3. Programmatically remove the item using .remove().
  4. Click on any item on the available side, and it does not get added to the selected side.
  5. You get the below client-side error.

multiselect_error

I have fixed it using the below code (line # 1084).

var element = this._elements[optElement.data('element-index')]; if (element != null || element !== undefined) this._elements[optElement.data('element-index')] .listElement(optElement.prop('disabled') ? "add" : "remove") + "Class";

In order to get the option deselected, I have used the below line of code (not sure of any method available within multiselect to deselect it).

$('#id option[value="0"]').removeAttr('selected'); $('#id).multiselect('refresh');