2013-03-18 81 views
1
结合

我是新来作为一个整体(剑道UI & & MVVM)。剑道UI MVVM数据与JayData

我想要一个下拉列表绑定在本地数据库,它的上线抛出一个错误标记// < < < < < <

我在做什么错在这里? - 我已经看到了JayData上可用的示例,但它并未清楚如何绑定本地数据库。

我的代码看起来像这样。

<div id="wrapper"> 
     <div id="NESTForm"> 

      <select data-role="dropdownlist" data-value-field="UserID" data-text-field="Name" 
       data-bind="source: userSource"> 
      </select> 



     </div> 
    </div> 
    <script> 
     var userDB; 
     $(document).ready(function() { 


      $data.Entity.extend("Users", 
      { 
       UserID: { type: "int", key: true, required: true }, 
       Name: { type: "string", required: true } 

      }); 


      $data.EntityContext.extend("EXAMPLEDB", { 
       Users: { type: $data.EntitySet, elementType: Users } 
      }); 

      userDB = new EXAMPLEDB({ 
       name: "webSql", databaseName: "EXMPLEDB", 
       dbCreation: $data.storageProviders.DbCreationType.DropTableIfChange 
      }); 


      var viewModel = kendo.observable({ 

       //Initial data binders , 
       userSource: userDB.Users.asKendoDataSource() //<<<<<< this throws error 



      }); 

      // apply the bindings 
      kendo.bind(document.body.children, viewModel); 

     }); 

    </script> 

的错误是

Uncaught TypeError: Object function (a,b){var c=this,d,e;c.trigger(w,{field:a}),a==="this"?d=c:(e=O[a]=O[a]||n.getter(a,!0),d=e(c),b&&typeof d=="function"&&(d=d.call(c)));return d} has no method 'push' 

回答

0

我现在不能尝试它,它看起来只是你要等确定为你的数据库做准备,是这样的:

userDB.onReady(function() { 
var viewModel = ...