我为sap.m.Input创建了自定义扩展。在onAfterRendering我想用jquery-maskmoney使用如下掩盖值:扩展sap.m.Input:onAfterRendering方法不起作用
$('#'+this.getId()+'-inner').maskMoney({ thousands : '', decimal : '.' });'
当我在控制台敷面膜,一切工作正常。但是,当我尝试 添加它在onAfterRendering方法,我得到了一些错误,当我试图给setValue:
amountInputControl.setValue(data.amount); // Its is an instance of NumericInput
错误:
TypeError: Cannot read property 'val' of undefined
at sap.m.InputBase._getInputValue (InputBase.js:9)
at sap.m.InputBase.updateDomValue (InputBase.js:32)
at sap.m.InputBase.setValue (InputBase.js:34)
at sap.ui.controller.updateFieldsForReference //Here was executed operation setValue
NumericInput.js
jQuery.sap.declare("control.customInputTypes.NumericInput");
sap.ui.define(['jquery.sap.global', 'sap/m/Input'],
function(jQuery, BaseInput) {
"use strict";
var commonControlInput = BaseInput.extend('control.customInputTypes.NumericInput', /** @lends sap.m.Input.prototype */ {
metadata: {},
renderer : {
render : function(oRm, oControl) {
sap.m.InputRenderer.render(oRm, oControl);
}
}
});
commonControlInput.prototype.onAfterRendering = function() {
$('#'+this.getId()+'-inner').maskMoney({ thousands : '', decimal : '.' });
};
return commonControlInput;
}, /* bExport= */ true);
我甚至没有触及InputBase类,所以我不知道什么是错的?如果我不应用这个面具一切正常。 也许我不能在控件的onAfterRendering方法中使用jQuery?
你能提一下SAPUI5版本和jQuery-maskmoney版本吗?我试过你的代码,并没有遇到任何问题。 –