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

Kendo popup close and open again

1 Answer 698 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alexandra
Top achievements
Rank 1
Alexandra asked on 13 Oct 2017, 07:58 AM
Hi,

I am tring to define a popup menu that will be opened from multiple buttons on the screen.
I have defined the panel to be opened like so:
var popup = $("#tableMenu").kendoPopup({
    origin: "bottom left",
    position: "top left",
    collision: "fit",
}).data("kendoPopup");


And on the button I am trying to close the popup and then open it again. The reason I do this is because I what to change the location

$(".sk-showhide-icon").on("click", function (e) {
    e.preventDefault();
    e.stopPropagation();
    popup.close();
    popup.setOptions({ anchor: $(this) });
    popup.open();
});


But the above code does not work. The popup is not closed and the open does nothing.
Can I achieve this?

The reason I do not want to define the popup multiple times is because the menu contains checkboxes that have to have the same checked/unchecked state when it is opened. It is something similar with the show columns from the telerik grid.

1 Answer, 1 is accepted

Sort by
0
Accepted
Nencho
Telerik team
answered on 16 Oct 2017, 12:19 PM
Hello Alexandra,

In order to achieve the desired functionality, I would suggest you to implement a slight timeOut. This is needed, because then the setOptions method is used, the widget is recreated and it take a bit time to finish this operation. Please consider the below implementation:

$(".sk-showhide-icon").click(function(z){
       var popup = $("#tableMenu").getKendoPopup();
        z.preventDefault();
        z.stopPropagation();
         popup.close();     
         popup.setOptions({ anchor: $(this) });
         setTimeout(function(y){popup.open();}, 100)
       })

Below is a dojo example on the matter:
https://dojo.telerik.com/aHoFAL/6

Regards,
Nencho
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Alexandra
Top achievements
Rank 1
Answers by
Nencho
Telerik team
Share this question
or