forked from extern/egroupware
onkeypress handler for textbox and number widget
This commit is contained in:
parent
49d4a864b7
commit
caa1f2247d
@ -94,7 +94,14 @@ var et2_number = et2_textbox.extend(
|
|||||||
this.input.addClass("et2_textbox");
|
this.input.addClass("et2_textbox");
|
||||||
// bind invalid event to change, to trigger our validation
|
// bind invalid event to change, to trigger our validation
|
||||||
this.input.on('invalid', jQuery.proxy(this.change, this));
|
this.input.on('invalid', jQuery.proxy(this.change, this));
|
||||||
|
if (this.options.onkeypress && typeof this.options.onkeypress == 'function')
|
||||||
|
{
|
||||||
|
var self = this;
|
||||||
|
this.input.keypress(function(_ev)
|
||||||
|
{
|
||||||
|
return self.options.onkeypress.call(this, _ev, self);
|
||||||
|
});
|
||||||
|
}
|
||||||
this.setDOMNode(this.input[0]);
|
this.setDOMNode(this.input[0]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -74,6 +74,12 @@ var et2_textbox = et2_inputWidget.extend([et2_IResizeable],
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "",
|
"default": "",
|
||||||
"description": "Weither or not browser should autocomplete that field: 'on', 'off', 'default' (use attribute from form)"
|
"description": "Weither or not browser should autocomplete that field: 'on', 'off', 'default' (use attribute from form)"
|
||||||
|
},
|
||||||
|
onkeypress: {
|
||||||
|
name: "onKeypress",
|
||||||
|
type: "js",
|
||||||
|
default: et2_no_init,
|
||||||
|
description: "JS code or app.$app.$method called when key is pressed, return false cancels it."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -137,6 +143,21 @@ var et2_textbox = et2_inputWidget.extend([et2_IResizeable],
|
|||||||
{
|
{
|
||||||
this.set_value(this.options.value);
|
this.set_value(this.options.value);
|
||||||
}
|
}
|
||||||
|
if (this.options.onkeypress && typeof this.options.onkeypress == 'function')
|
||||||
|
{
|
||||||
|
var self = this;
|
||||||
|
this.input.keypress(function(_ev)
|
||||||
|
{
|
||||||
|
return self.options.onkeypress.call(this, _ev, self);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
var node = this.getInputNode();
|
||||||
|
if (node) $j(node).unbind("keypress");
|
||||||
|
|
||||||
|
this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
getValue: function()
|
getValue: function()
|
||||||
|
Loading…
Reference in New Issue
Block a user