不更新時我有一個observable有兩個派生成員,而這兩個派生成員反過來使用一個函數來操縱主數據的值。簡單的函數,可以進行一些字符串操作。Kendo UI Databound對象在派生成員與函數
當第一次加載並綁定到DOM片段時,它一切正常,但如果我然後更新值,派生值不會更改。不文本從miniavatar改變的價值
//mvvm
window.userdata = kendo.observable({
user: null,
miniavatar: function() { return getAvatarUriWithRadius(this.get('user.AvatarPublicId'), 36); },
});
//first bind which works
$.post('Account/GetUser', {}, function(response) {
window.userdata.set('user', response.Data);
//bind the notifications and overduetasks
kendo.bind($('#top'), window.userdata.user);
});
//DOM
<div id="top">
<div id="latesthig" class="floatright">
<div data-bind="attr:{class:latesthigclass}"></div>
</div>
<div class="button floatright"><a id="search" href="#"></a></div>
<span class="button" id="addnote" title="add note"><span></span></span>
<span data-bind="text:miniavatar"></span>
<div id="messages"></div>
</div>
後續更改派生成員
window.userdata.set('user.AvatarPublicId', value);
任何想法的人?某個地方愚蠢的錯誤? TIA
應當指出的是,getAvatarUriWithRadius具有全局範圍。當值被改變時,該函數甚至沒有被觸發。 – mrmoosehead 2013-03-15 11:23:00
Account/GetUser返回什麼?據我所知是一個'string',你如何訪問'response.Data'? – OnaBai 2013-03-15 11:51:36
我們有一個Jsonwrapper,我們將所有數據全部返回 - 所以響應始終是Json對象,其中包含數據 – mrmoosehead 2013-03-15 16:28:55