Keti777 / dropdown-check-list

Automatically exported from code.google.com/p/dropdown-check-list
1 stars 0 forks source link

Destroy and append #89

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.create multiple selection
 <select name="test" id="test" multiple="multiple">
   <option>One</option>
   <option>two</option>
   <option>three</option>
 </select>

2. set dropdownchecklist using function
function change()
{
  $("#test").dropdownchecklist();
}

3. create function to append new option
function append()
{
    $("#test").dropdownchecklist("destroy");
    var optn = document.createElement("OPTION");
    optn.text = "four";
    optn.value = "four";
    $("#test").options.add(optn);
    $("#test").dropdownchecklist();
}

What is the expected output? What do you see instead?
option value 'four' should now be in the drop down but the dropdown does
not change.

What version of the product are you using? On what operating system?
0.9

Original issue reported on code.google.com by ash...@gmail.com on 9 Apr 2010 at 2:54

GoogleCodeExporter commented 8 years ago
The script is not correct because $("#test").options.add(optn); is crashing. 
Have a 
look in a debugger. If you use jquery to refer to an element $("#test") also 
use the 
jquery functions like:

$('#test').append(
$('<option></option>').val("four").html("four")
);

Hope it helps.

Original comment by adrian.tosca on 22 Apr 2010 at 7:35