You are viewing limited content. For full access, please sign in.

Question

Question

Appending a collection after "add" button

asked on November 20, 2017 Show version history

I am working with one our customers on a Forms issue. 

When the user inputs an ID (TalentEd CID), it does a lookup to populate the First Name, Middle Name, Last Name, Current Emplid and also the Applicant's Email. If the TalentEd ID does not have a Current Emplid associated with the user then he/she is only allowed limited selection in the Position drop down list. There would be an alert prompt, 'The applicant must be a current employee for this position' if they select the wrong Position.

The problem is the event listeners are not passing along to a duplicate collections field which prevents JQUERY from running a check on a field value. After clicking the "Add" button the 2 functionalities that are not working is the Current Emplid is no longer a read only, and it does not prompt the alert when we select a position that is not allowed for the user. 

 

Here is the JavaScript codes:

  	function positionCheck() {
      var id = $(this).attr('id');
      if (($('.vPos :selected').val() == "01" || $('.vPos :selected').val() == "02" || $('.vPos :selected').val() == "05" || $('.vPos :selected').val() == "06" || $('.vPos :selected').val() == "07" || $('.vPos :selected').val() == "08" || $('.vPos :selected').val() == "09" || $('.vPos :selected').val() == "10" || $('.vPos :selected').val() == "11" || $('.vPos :selected').val() == "12" || $('.vPos :selected').val() == "13" || $('.vPos :selected').val() == "14" || $('.vPos :selected').val() == "16") && $('.vCurrEmplid input').val() == "") {
        alert('The applicant must be a current employee for this position');
        $('.Submit').hide();
        return false;
	  }else{
        $('.Submit').show();
	}
    } 
  
    $('#form1').submit(function(){
      $('.rpx').each(function(){
       if (!positionCheck()){ 
        return false;
       }
      });
    });  
  
   $('.cf-collection-append').on('click', function() {});

We have also tried to do...

$(document).on('click','#q334 > a', function() {});

AND

$('.cf-collection-append').click(function() {

    $.addCollection($(this));

});

 

They are currently on version 10.1.0.559. We have been told to upgrade to 10.2.1 but that is planned for months down the line and would like to see if anyone has had this issue and/or solution. 

Any help would be appreciated! :) Thank you!

0 0

Replies

replied on December 7, 2017

Hi Jonathan,

In your script you didn't separate calculation for different sets of collection, so it would only calculate on the first set.

I'm not sure what the "rpx" class is on and I assume that is the class of the collection. The script could be like:

   	function positionCheck(row) {
      var vPosValue = row.find('.vPos :selected').val();
      var vCurrEmplidValue = row.find('.vCurrEmplid input').val();
     if ((vPosValue == "01" || vPosValue == "02" || vPosValue == "05" || vPosValue == "06" || vPosValue == "07" || vPosValue == "08" || vPosValue == "09" || vPosValue == "10" || vPosValue == "11" || vPosValue == "12" || vPosValue == "13" || vPosValue == "14" || vPosValue == "16") && vCurrEmplidValue == "") {
       alert('The applicant must be a current employee for this position');
       $('.Submit').hide();
       return false;
        }else{
             $('.Submit').show();
          return true;
      }
   } 
 
   $('#form1').submit(function(){
     var allpass = true;
     var rows = $('.rpx .cf-collection').children();
     rows.each(function(){
      if (!positionCheck($(this))){ 
       allpass = false;
      }
     });
     if (!allpass)
       return false;
   });

 

0 0
replied on December 8, 2017

Hey Rui, 

I appreciate you updating my answers topic and the class 'rpx' is tied to the ul class

I will test with the script you have provided me and update you on the results.

0 0
replied on December 10, 2017

So it's a generally class for collection fields. It's better not to use this general class; you can try add a specific class to the collection and replace it in the script.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.