0
如何將OptionsServer正確發送到服務器?因爲我試圖將選中的複選框的值發送到服務器。knockout observableArray訪問
我的代碼:
var viewModel = {};
viewModel.ui = {};
viewModel.ui.FlashbackReport = {
ChoosenEmails : ko.observableArray(),
ChoosenOptions : ko.observableArray(),
OptionsServer : ko.observableArray(),
Options : ko.observableArray([ "New Contacts", "Updated Contacts","Verified Contacts" ]),
OptionsToSend: ko.computed({
read : function() {
var viewModelShortcut= viewModel.ui.FlashbackReport;
if (viewModelShortcut.ChoosenOptions()=="New Contacts")
viewModelShortcut.OptionsServer.push('NEW');
else if (viewModelShortcut.ChoosenOptions()=="Updated Contacts")
viewModelShortcut.OptionsServer.push('BETTER');
else if (viewModelShortcut.ChoosenOptions()=="Verified Contacts")
viewModelShortcut.OptionsServer.push('NOT_BETTER');
/* else if (viewModelShortcut.ChoosenOptions()[0]=="New Contacts"
&& viewModelShortcut.ChoosenOptions()[1]=="Updated Contacts"
&& viewModelShortcut.ChoosenOptions()[2]=="Verified Contacts")
viewModelShortcut.OptionsServer.push('NEW','BETTER','NOT_BETTER');
*/
},
deferEvaluation: true
}),
哦~~陸續嘗試的工作!謝謝 !! – user2587781
@ user2587781不客氣 – Damien
你能幫我再次選擇我的服務器嗎? 我有3個複選框:新的聯繫人,更新聯繫人,驗證接觸 我想正確的價值觀發送到我的服務器,但如果用戶檢查,取消選中複選框我OptionsServer陣列不是編輯... – user2587781