-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hellooo!! I work with zk version 6.5.2 I would like avoid validation before submit and I have tryed this solution:
The code noValidateOnBlur.js that I have used is:
zk.afterLoad("zul.inp", function () {
zk.$package("zul.inp").TextboxNoErrorOnCtrlKey = zk.$extends(zul.inp.Textbox, {
doBlur_: function (event) {
this.getConstraint().getFlags().NO_EMPTY=false;
this.$supers("doBlur_", event); //FAIL THIS LINE
this.getConstraint().getFlags().NO_EMPTY=true;
}
});
});
and the .zul:
<zk xmlns:w="client">
<?script type="text/javascript" src="/js/noValidateOnBlur.js" ?>
<window>
<textbox w:use="zul.inp.TextboxNoErrorOnCtrlKey" id="tbCompany" hflex="1" constraint="no empty"/>
</window>
</zk>
It's working well for me in Chrome but when I execute in Explorer and move out the text fails in line .js(noted aboved)
Message: An object array or arguments were expected
Line: 9
Character: 9732
Code: 0
URI: /myportal/zkau/web/439b83ff/js/zk.wpd
What is wrong? Thanks in advance (Sorry for my bad English)
It should be (see API docs)
this.$supers("doBlur_", arguments); //THIS LINE SHOULD NOT FAIL
arguments
is an implicit variable in JS that contains all the arguments of the current method call, and so it is easy and save to pass the arguments on to the overridden method.
If you want to pass the arguments explicitly you can use $super() instead of $supers()
I don't know why it works in chrome... anyway the correct usage is with an array of arguments.
Robert
Ok! It's true. The correct code could be:
zk.afterLoad("zul.inp", function () {
zk.$package("zul.inp").TextboxNoErrorOnCtrlKey = zk.$extends(zul.inp.Textbox, {
doBlur_: function (event) {
this.getConstraint().getFlags().NO_EMPTY=false;
this.$super("doBlur_", event);
this.getConstraint().getFlags().NO_EMPTY=true;
}
});
});
In case of someone is interested I have worked with no validation onBlur and the code is just like this:
zk.afterLoad("zul.inp", function () {
zk.$package("zul.inp").TextboxNoErrorOnCtrlKey = zk.$extends(zul.inp.Textbox, {
doBlur_: function (event) {
this.getConstraint().getFlags().NO_EMPTY=false;
this.$super("doBlur_", event);
this.getConstraint().getFlags().NO_EMPTY=true;
}
});
});
zk.afterLoad("zul.db", function () {
zk.$package("zul.db").DateboxNoErrorOnCtrlKey = zk.$extends(zul.db.Datebox, {
doBlur_: function (event) {
var aux = this.getConstraint();
var arrayConstraints = this.getConstraint().split(",");
var strWithoutNoEmpty = "";
for (var i = 0; i < arrayConstraints.length; i++) {
if (arrayConstraints[i].indexOf("no empty") == -1) {
strWithoutNoEmpty += arrayConstraints[i] + ",";
}
}
if (strWithoutNoEmpty.length > 0) {
strWithoutNoEmpty = strWithoutNoEmpty.substring(0, strWithoutNoEmpty.length - 1);
}
this.setConstraint(strWithoutNoEmpty);
this.$super("doBlur_", event);
this.setConstraint(aux);
}
});
});
zk.afterLoad("zul.inp", function () {
zk.$package("zul.inp").ComboboxNoErrorOnCtrlKey = zk.$extends(zul.inp.Combobox, {
doBlur_: function (event) {
this.getConstraint().getFlags().NO_EMPTY=false;
this.$super("doBlur_", event);
this.getConstraint().getFlags().NO_EMPTY=true;
}
});
});
Thank you Rober!
Asked: 2014-04-30 12:07:58 +0800
Seen: 30 times
Last updated: May 07 '14
Uncaught TypeError: Cannot read property 'offsetHeight' of null
zk.wpd JS error, with window inside window
unwanted logging of custom WrongValueException
How to Disable Mandatory Constraint for email textbox
wrong valueException come in front of modal popup [closed]
textbox constraint="no empty", how to cancel ? [closed]
[solved]textbox constraint="no empty", how to cancel it?
Zk Textbox constraint fire only once
Validate datebox invalid input with validators
MVVM, How to display @validator error like the constraint attribut error ?