Donate

Unable to get value of the property 'nodeType': object is null or undefined (Knockout JS)

After completing a simple binding using Knockout Javascript framework, I decided to transfer the script tags to the header section of the page. Upon running my code, I stumbled upon an error as stated on the title. I believe, the DOM elements have not been initialized when the binding occurs. One solution I came up was to transfer the view model script inside the document ready function.
<head runat="server">  
   <title>Integrate jQuery with Knockout!</title>  
   <script type="text/javascript" src="Scripts/knockout-3.1.0.js"></script>  
   <script type="text/javascript" src="Scripts/jquery-1.7.1.min.js"></script>  
   <script type="text/javascript">  
     $(document).ready(function() {  
       var myViewModel = {  
         personName: 'PsychoGenes',  
         personAge: 33  
       };  
       ko.applyBindings(myViewModel);  
     });  
   </script>  
 </head>  

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.