Search code examples
javascriptdojomulti-select

dojo remove item from dijit.form.MultiSelect


I have a problem... I tried to remove the selected items from dijit.form.MultiSelect when I click on button, but don't work...

Here is the code:

btnRemove = dijit.byId("btnRemove");   // button ID  
List= dijit.byId("List");  // ID List of items which I want             
                           // to  remove when click on someone item
on(btnRemove , "click", function(evt){  // onClick event            
alert(dijit.byId("List").attr("value")); // returns a label of element

// here must be a code to remove a selected item from MultiSelect - but don't work...
List.containerNode.removeChild(dijit.byId("List").attr("value"));

});

all code is in Javascript.. thanks


Solution

  • I solved this problem... if any will need this:

    because I didn't find that dijit.form.MultiSelect has a removeChild option, I used a another hidden dijit.form.MultiSelect in which move items from the first MultiSelect...

    Code for this is:

    btnRemove = dijit.byId("btnRemove");
    on(btnRemove, "click", function(evt){
    dijit.byId("Removed").addSelected(dijit.byId("List"));      
    });
    

    where Removed is the ID of hidden MultiSelect and the List is ID of a visible dijit.form.MultiSelect