This is a migrated thread and some comments may be shown as answers.

Confirmation on clicking delete button in multiselect control

1 Answer 726 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Mahesh
Top achievements
Rank 1
Mahesh asked on 23 Mar 2016, 11:58 PM

In multiselect control, when user click delete icons of a selected value , it should alert confirmation message and based on user  input "Yes" , "No" it should delete the selection or cancel it.

I tried as below, it shows confirmation popup but is not waiting for user confirmation

$(".k-delete").click(function (e) {
            //window.event.cancelBubble = true;
            //e.stopPropagation();
            currentSelection = s.value()
            $("#dlgDeleteSecFromAnalyst").html("Are you sure you want to remove.. clicked.");
            $("#dlgDeleteSecFromAnalyst").dialog("open"); 

        })

1 Answer, 1 is accepted

Sort by
0
Dimiter Topalov
Telerik team
answered on 25 Mar 2016, 11:42 AM
Hi Mahesh,

You can handle the change event of the MultuSelect and attach a handler to all the items that are selected from the dropdown. Then if the user clicks the "X" to remove any of them, a confirm pops up, and if the user selects "Cancel" the event is stopped from reaching its destination, else the item is removed:

$("#multiselect").kendoMultiSelect({
  change: function(e) {
    e.sender.wrapper.find('li.k-button').off().one('click', function(event){
      if($(event.target).hasClass('k-i-close')){
        if(!confirm("Are you sure?")){
          event.stopPropagation();
        };
      }
   });

Multiple attachment of the handler to the same event is avoided by unbinding before attaching the handler (... off()...).

I hope this helps.

Regards,
Dimiter Topalov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
MultiSelect
Asked by
Mahesh
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or