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

Unable to Instantiate Window in AngularJS

3 Answers 47 Views
Window
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 17 Sep 2020, 01:29 PM

Ok everyone, so I am at a loss here why I am unable to get the Kendo window to open. In my quickwatch in the IDE, the window seems to build, but does not inherit the methods for Kendo Windows. I have followed all of the steps on Telerik's documentation about ordering of scripts, ensuring there are not multiple references to jQuery, etc. Alas, I cannot find the issue here. Code is as follows:

HTML:

 

<div class="panel panel-primary k-popup k-window"
 id="groupMembershipWindow">
<div class="table-bordered">
    <h1>
        THIS IS A TEST
    </h1>
    <table>
        <thead>
            Group Members
        </thead>
        <tbody>
            <tr>
                <td></td>
            </tr>
            <tr></tr>
        </tbody>
    </table>
</div>

AngularJS

$scope.buildPopupWindow = function () {
        var windowOptions = {
            title: "Fuel Group Memberships",
            width: 1400,
            height: 400,
            modal: true,
            content: "app/groups/groupMembershipsPopupWindow.html",
            center: true,
            visible: false,
            actions: ["close"],
            //open: function (e) {
            //    $("#groupMembershipWindow").open();
            //},
            close: function (e) {
                angular.element("#groupMembershipWindow").destroy();
            }
        };
        
        var groupWindow = angular.element("#groupMembershipWindow");
        groupWindow.kendoWindow(windowOptions);
        groupWindow.data("kendoWindow");
        $scope.data.groups.currentPopup = groupWindow;
        groupWindow.center().open();
    };

3 Answers, 1 is accepted

Sort by
0
Ivan Danchev
Telerik team
answered on 21 Sep 2020, 11:01 AM

Hello Robert,

The issue comes from trying to use the center and open API methods on the groupWindow object:

groupWindow.center().open();

Instead, you should declare a new variable that holds the reference to the Window's instance:

var myWindow = groupWindow.data("kendoWindow");
myWindow.center().open();

Here's a dojo example that demonstrates that: https://dojo.telerik.com/ODidarOR/2

 

Regards,
Ivan Danchev
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Robert
Top achievements
Rank 1
answered on 21 Sep 2020, 01:35 PM

Alright, 

so changing to the following left the myWindow as undefined, and thus could not call the center and open methods still:

var groupWindow = $("#groupMembershipWindow").kendoWindow(windowOptions);
var myWindow = groupWindow.data("kendoWindow");
$scope.data.groups.currentPopup = groupWindow;
myWindow.center().open();
0
Ivan Danchev
Telerik team
answered on 23 Sep 2020, 11:48 AM

Robert,

myWindow holds a reference to the Window and the API methods work in the example I linked. Could you modify it accordingly and demonstrate the issue?

Regards,
Ivan Danchev
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Window
Asked by
Robert
Top achievements
Rank 1
Answers by
Ivan Danchev
Telerik team
Robert
Top achievements
Rank 1
Share this question
or