Jquery delete selectable item text

509 views Asked by At

I have a code that works but there is a little bug there. I have selectable menu when I select items it shows which items are selected. When I press delete button it deletes the selected items and text but when I click again to some item it shows deleted items name in selected items menu. How can I avoid this? http://jsfiddle.net/dx5c04p5/1/

<style>
  #feedback { font-size: 1.4em;}
  span{ text-decoration: underline; background-color:#b6be98; }
  #selectable .ui-selecting { background: white; }
  #selectable .ui-selected { background: #91b547; color: white; }
  #selectable { list-style-type: none; margin: 0; padding: 0; width: 60%; }
  #selectable li { margin: 3px; padding: 0.4em; font-size: 1.4em; height: 18px; }
  </style>
    </style>

    <script type="text/javascript">
$(function() {

    $( "#selectable" ).selectable({
      stop: function() {
        var result = $( "#select-result" ).empty();
        $( ".ui-selected", this ).each(function() {
          result.append( " " + ( $(this).text()));
        });
      }

    });

    $("#delete").click(function(){
        $('#selectable .ui-selected').hide();   
        $( "#select-result" ).empty();
    }); 
0

There are 0 answers