2013-01-08 31 views
0

我是knockout.js的新手,我在使用MVC4和Breez.js的簡單測試頁面時出現錯誤。我想將數據綁定到一個表。MVC4,微風和淘汰賽的數據綁定問題

@{Layout = null;} 
<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="utf-8" /> 
     <meta name="viewport" content="width=device-width" /> 
     <title>Breeze Test</title> 
     <link rel="stylesheet" href="/Content/breezesample.css" /> 
    </head> 
    <body> 
     <header> 
      <div class="content-wrapper"> 
       <div class="float-left"> 
        <p class="site-title"> 
         <a href="~/">Breeze Test</a> 
        </p> 
       </div> 
      </div> 
     </header> 
     <div id="body"> 
      <section id="content" class="content-wrapper main-content"> 

       <script type="text/x-jquery-tmpl" id="BookTableTemplate"> 
        <table> 
         <thead> 
          <tr> 
           <th>Title</th> 
           <th>Author</th> 
           <th>ISBN</th> 
           <th>Price</th> 
           <th>Read?</th> 
          </tr> 
         </thead> 
         <tbody data-bind="template: {name:'bookRowTemplate', foreach:books}"> 
         </tbody> 
        </table> 
       </script> 

       <script type="text/x-jquery-tmpl" id="bookRowTemplate"> 
        <tr> 
         <td>${Title}</td> 
         <td>${Author}</td> 
         <td>${ISBN}</td> 
         <td>${Price}</td> 
         <td>${IsRead}</td> 
        </tr> 
       </script> 

       <div data-bind="visible: show" style="display: none"> 
        <a href="#" data-bind="click: save">Save</a>&nbsp; 
         <input type="checkbox" data-bind="checked: IncludeRead" /> 
        include read 

        <div data-bind="template: 'BookTableTemplate'"></div> 
       </div> 
       <div id="logmessages"></div> 
      </section> 
     </div> 
     <!--3rd party library scripts --> 
     <script src="/Scripts/jquery-1.7.1.min.js"></script> 
     <script src="/Scripts/knockout-2.1.0.js"></script> 
     <script src="/Scripts/q.js"></script> 
     <script src="/Scripts/breeze.debug.js"></script> 

     <!-- Application scripts --> 
     <script src="/Scripts/app/logger.js"></script> 
     <script src="/Scripts/app/bookViewModel.js"></script> 
    </body> 
</html> 

非但沒有數據輸出的獲取: $ {標題} $ {作者} $ {ISBN} $ {售價} $ {IsRead}

+0

我發現,我能做到這樣:

回答