keydown 事件中的值未更改
The value not changed in the keydown event
我有以下功能:
formCreated = function (event, data) {
console.log(data.formType); // output: 'edit'
$('body').on('keydown', function (e) {
if (e.ctrlKey && e.which == 80) {
e.preventDefault();
e.stopPropagation();
if (data.formType == 'create') // not changed until page refresh
alert('save the record');
else if (data.formType == 'edit')
_connectPrinter(data);
}
});
}
保存记录后 data.formType
变为 'edit',但在页面刷新之前事件内的值没有改变。
尝试 http://api.jquery.com/off/、
$('body').off('keydown').on('keydown', function (e) {
// your code here
}
.off() 方法删除注册值。
我有以下功能:
formCreated = function (event, data) {
console.log(data.formType); // output: 'edit'
$('body').on('keydown', function (e) {
if (e.ctrlKey && e.which == 80) {
e.preventDefault();
e.stopPropagation();
if (data.formType == 'create') // not changed until page refresh
alert('save the record');
else if (data.formType == 'edit')
_connectPrinter(data);
}
});
}
保存记录后 data.formType
变为 'edit',但在页面刷新之前事件内的值没有改变。
尝试 http://api.jquery.com/off/、
$('body').off('keydown').on('keydown', function (e) {
// your code here
}
.off() 方法删除注册值。