這個問題似乎基本,但是不要緊我做什麼(基於SOV的各種帖子中,我經歷了)我只是不能得到這個事件在我Devextreme應用火JQuery的onBlur事件不觸發
的前提... 我想要做的就是用輸入的文本更新現有變量的值。變量的值從另一個頁面繼承。我需要從寫入文本框的文本更新變量的值。這就是我想要做的。
這裏是我的html代碼:
<div class="dx-field-label">Code: </div>
<div class="dx-field-value" id="txtCode" data-bind="dxTextBox: { value: CustomerCode, placeholder: 'Enter Code', showClearButton: true }"></div>
</div>
這裏是我的JS代碼:
var viewModel = {
// CustomerID: params.CustomerID,
// CustomerName: ko.observable(params.CustomerName),
//CustomerEmail: ko.observable(params.CustomerEmail),
// CustomerID: ko.observable(params.CustomerID),
Continue: function() {
alert('Saved');
},
CustomerID: CustomerID,
CustomerName: CustomerName,
CustomerCode: CustomerCode,
CustomerEmail: CustomerEmail,
AddCustomer: AddCustomer,
//Add Customer
};
$('#txtCode').on('blur', 'txtCode', function() {
CustomerCode = $("#txtCode").dxTextBox('option', 'value');
console.log(CustomerCode);
});
任何意見,將不勝感激
編輯
OK,我現在已經做了這個:
CustomerID;
CustomerName.trim();
CustomerCode.trim();
CustomerEmail.trim();
ko.applyBindings({
ChangedCustomerCode: ko.observable(),
CodeFocusOut: function(e){
ChangedCustomerCode: value;
console.log(value);
console.log(ChangedCustomerCode);
CustomerCode: ChangedCustomerCode;
console.log(CustomerCode);
}
});
var viewModel = {
Continue: function() {
alert('Saved');
},
CustomerID: CustomerID,
CustomerName: CustomerName,
CustomerCode: CustomerCode,
CustomerEmail: CustomerEmail,
AddCustomer: AddCustomer,
};
return viewModel;
};
但它告訴我,我不能將綁定多次應用到相同的elemenet。我該怎麼辦?
當綁定事件,''txtCode'',缺少'.'?或者只是'$('#txtCode')。on('blur',function(){' – Tushar
也請確保在'#txtCode'內輸入'.txtCode'類 – Mitul