我对Durandal很新.我对KnockoutJS有一点经验.我试图从一个从php文件中检索到的json填充一个observableArray.然后我尝试将数组加载到表中.在首次加载页面时将数据加载到表中似乎存在问题.我执行一个system.log(客户)只是为了确保数据在observableArray中.当我刷新页面时,数据被加载到表中,就像我想要的那样.似乎observableArray正在填充,但视图未更新.
我想知道我错误的是它没有加载到页面的第一个加载.这是我和durandal一起玩的测试网站:http://dev.codeplanetapps.com/spa/ .加载后,点击"客户".有问题的页面是http://dev.codeplanetapps.com/spa/#/customers.当直接加载该页面时,它工作正常,但是当我从主页面加载应用程序然后切换到客户时,它不会正确加载表.在此先感谢您的帮助.
这是观点:
<div>
<!-- Form to add new customer -->
<form class="form-inline customerForm">
<span>Add New Customer</span>
<input type="text" data-bind="value: inputName" placeholder="Name" />
<input type="text" class="date input-small" data-bind="value: inputDOB" placeholder="Date of Birth" />
<input type="text" class="input-small" data-bind="value: inputPhone" placeholder="Phone" />
<input type="text" data-bind="value: inputEmail" placeholder="Email" />
<button type="submit" class="btn btn-primary" data-bind="click: submitCustomer">Add</button>
</form>
<table class="table table-hover table-bordered customerTable">
<thead>
<tr>
<th>Name</th>
<th>DOB</th>
<th>Phone Number</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody data-bind="foreach: customers">
<tr>
<td data-bind="text: name"></td> …Run Code Online (Sandbox Code Playgroud)