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

kendo.destroy() not working

5 Answers 904 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Madreza
Top achievements
Rank 1
Madreza asked on 22 Jun 2016, 09:42 AM

when i remove an dom element all effect still exist in kendo, and kendo try to get injector of those removed elements that i removed.
how can i destroy them to stop kendo for get the injector of them.
the function of kendo is setupRebind
and here is my code:

 

function removeAllChildren(level) {
    if (vm.dataLevel.length > vm.currentSender + 1) {
 
        for (var i = vm.dataLevel.length - 1; i > vm.currentSender; i--) {
            var idToRemove = "#level" + i + "";
            var idCss = "#data-level-" + i + "";
            var selectedData = angular.element(idCss).data("kendoDropDownList");
            kendo.unbind(angular.element(idCss));
            kendo.unbind(angular.element(idToRemove));
            selectedData.destroy();
            angular.element(document.querySelector(idToRemove)).remove();
        }
        vm.dataLevel.splice(vm.currentSender + 1);
        vm.currentElement = "#level" + vm.currentSender + "";
    }
}

 

but after this, i traced and i saw that my idToRemove elements still exist in kendo and kendo want to access them via this line

 

var compile = element.injector().get('$compile');
widget._destroy();

 

my app works very good but i have error for every removed element.
Error:

 

TypeError: Cannot read property 'get' of undefined
at http://localhost:46255/Scripts/kendo.all.js:118139:53
at Scope.$digest (http://localhost:46255/scripts/angular.js:17073:23)
at http://localhost:46255/scripts/angular.js:17268:26
at completeOutstandingRequest (http://localhost:46255/scripts/angular.js:5869:10)
at http://localhost:46255/scripts/angular.js:6145:7

 

please help me :(

5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 24 Jun 2016, 07:27 AM
Hello,

Could you send us a repro demo that demonstrates the issue? This will help us to perform a more detailed investigation and find the cause of the erroneous behavior.

Regards,
Georgi Krustev
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Madreza
Top achievements
Rank 1
answered on 25 Jun 2016, 03:39 AM

i can give you all of my controller and html codes, when we create an kendo directive, its works good but when we remove it, the injector is undefined but kendo try to use it with a get function.

thanks for reply

0
Georgi Krustev
Telerik team
answered on 29 Jun 2016, 07:28 AM
Hello Madreza,

Thank you for the attached files. I reviewed the implementation and at first glance everything is correct. In order to continue with the investigation, would it be possible to send us a runnable demo which replicates the issue? You can try our Dojo service to create a runnable demo. This will help us a lot to observe the issue and find a solution much faster.

Regards,
Georgi Krustev
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
Madreza
Top achievements
Rank 1
answered on 30 Jun 2016, 05:08 AM

Hello Georgi,

Thank you for reply.

please at first clear my attached code, secondly my problem solved. i think its a bug, because my codes works very well when i clear dataSource but i get a undefined error when i use destroy method.

 

now my code is:

selectedData.setDataSource([]);
//selectedData.destroy();
angular.element(document.querySelector(idToRemove)).remove();

 

0
Georgi Krustev
Telerik team
answered on 30 Jun 2016, 09:01 AM
Hello Madreza,

Indeed, the exception thrown on widget.destroy() call is a peculiar problem. We would like to address it, but to do that we will need an isolated example that replicates the issue. This will gives us a foundation to start our investigation. Would it be possible to provide such repro demo?

Regards,
Georgi Krustev
Telerik
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
DropDownList
Asked by
Madreza
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Madreza
Top achievements
Rank 1
Share this question
or