Question

1
Replies
68
Views
Amitabha Ghosh (AmitabhaG)
Areteans

Areteans
IN
AmitabhaG Member since 2019 4 posts
Areteans
Posted: July 9, 2019
Last activity: July 10, 2019
Posted: 9 Jul 2019 7:37 EDT
Last activity: 10 Jul 2019 2:50 EDT
Closed

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?

Thanks in advance

User Experience
Moderation Team has archived post, This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.