Retrieve error DOM element in javascript
Hello,
I am writing custom javascript for custom UI functionality. What my requirement is I want to get the page auto scroll to the errors if there are errors in Tree navigation flow.
What I am finding when there are errors those error messages are appended to the respective required field wrappers which is wrapped under a class "iconErrorDiv".
Since those are appending those are being not able to retrieve in DOM elements.
I have tried all possible means
Below is my code.
var validationMethod = function(input){
var requiredField = $('.content-item.v-req.required');
var inputField = requiredField.find(input);
$.each(inputField,function( index, item ){
var $item = $(item);
var $name = $item.attr('name');
//console.log($name);
var $parent = $item.closest('.field-item');
//var errorField = $parent.find('.iconErrorDiv');
//var errorFieldID = $parent.find('#'+$name+'Error');
//console.log($(errorFieldID));
var x = pega.ctx.dom.getElementsByClassName('iconErrorDiv')[0];
console.log(x)
//if( errorField.length === 0 ){
//errorField.addClass("errors")
//}
})
}
var _input = $('input[type="text"]');
$('.workarea-view-footer').on('click',$cont_btn, function(){
validationMethod(_input);
})
But the errordivs are going undefined.
Can anyone help me to retrieve the appended error divs in javascript?
Hello,
I am writing custom javascript for custom UI functionality. What my requirement is I want to get the page auto scroll to the errors if there are errors in Tree navigation flow.
What I am finding when there are errors those error messages are appended to the respective required field wrappers which is wrapped under a class "iconErrorDiv".
Since those are appending those are being not able to retrieve in DOM elements.
I have tried all possible means
Below is my code.
var validationMethod = function(input){
var requiredField = $('.content-item.v-req.required');
var inputField = requiredField.find(input);
$.each(inputField,function( index, item ){
var $item = $(item);
var $name = $item.attr('name');
//console.log($name);
var $parent = $item.closest('.field-item');
//var errorField = $parent.find('.iconErrorDiv');
//var errorFieldID = $parent.find('#'+$name+'Error');
//console.log($(errorFieldID));
var x = pega.ctx.dom.getElementsByClassName('iconErrorDiv')[0];
console.log(x)
//if( errorField.length === 0 ){
//errorField.addClass("errors")
//}
})
}
var _input = $('input[type="text"]');
$('.workarea-view-footer').on('click',$cont_btn, function(){
validationMethod(_input);
})
But the errordivs are going undefined.
Can anyone help me to retrieve the appended error divs in javascript?
Thanks in advance