这个问题似乎基本,但是不要紧我做什么(基于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