When there is more than one remote will produce a bug
Closed this issue · 4 comments
When there is more than one remote will produce a bug, when the page is refreshed or the first time after loading, the first time to submit the form verification, the error message will flash and eventually disappear; possible reason is: # line54: $ each (_this.validElements () ajax callback mechanism problem; in the script block, blocking can clearly observe the implementation steps;
More than one remote? As in, the form will call two different URLs to verify the form? I would first suggest removing this plugin and see if it works as intended with just jquery-validation. However, without looking at an JsFiddle example, I am a little confused about how this is implemented and what you are ultimately trying to accomplish.
Hello, thanks for your reply, my test code is as follows
rules : {
parentName:{required : true},
telphone : {
required : true,
remote : {
url : "/testapi1",
type : "post",
dataType : "json",
data : {
'telphone' : function(){return $.trim($('#telphone').val())},
'id' : function(){return saveOrEdit=="create"? '0' : ''}
}
},
//"ck-phone" : true
},
newTelphone : {
//noequalto:'#telphone',
remote : {
url : "/testapi2",
type : "post",
dataType : "json",
data : {
'newTelphone' : function(){return $.trim($('#newTelphone').val())},
'id' : function(){return saveOrEdit=="create"? '0' : ''}
}
},
//"ck-phone" : true
}
`},`
After removing the component, you can get the expected results, and the direct use of 'success' and 'errorPlacement' rewrite can also be expected, the test code is as follows:
`success:function(a,e){
$(e).tooltip('destroy');
console.log('#',1,e)
},
unhighlight:function(e){console.log('#',2,e)},
errorPlacement:function(error,element){
var this_ = $(element);
this_.attr('data-original-title',error.text()).tooltip({
trigger:"manual"
}).tooltip('show');
}`
@rwx666888 Hmmmm. I have a feeling this is an async issue where the two POST request respond around the same time and each triggers a full form validation update.
Could you create an example of the bug in JSFiddle? There are too many variables like REST implementation, javascript library versions and markup that could be the root cause.
It has been confirmed that this bug was caused by the end of animation animations, similar to an asynchronous process, tooltip ('hide') immediately after the tooltip tooltip ('show'), with its hide animation not yet over, causing show As expected, my solution is to turn off the tooltip's animation, or setTimeout 300ms to tooltip ('show')