Friday, April 4, 2014

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  


Post a Comment