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

Question

Question

Table populated by lookup doesn't work right when table changes

asked on January 6, 2021

I have a table that changes when the search criteria change and that part works well.  My goal is that when the user clicks an entry on the ID column, that ID value is captured and the detail for that item will show in a section below (via another lookup).

This works pretty well until the user changes the search criteria for the table and a larger number of rows are returned than in the initial search. 

Using my example above, the first search returned 5 rows and clicking the ID field worked as expected for all rows.  Then I changed it to search for City Council Ordinances which returned 6 rows, and clicking the ID field in the 6th row doesn't capture the value; however, it does for rows 1-5.  It seems like the javascript only fires for the number of rows returned in the first search.

Has anyone else encountered this and found a solution?  Thanks for any comments!

 

0 0

Answer

SELECTED ANSWER
replied on January 6, 2021

Yes, this is normal. When rows are added to a table, they are literally added to the form. They did not exist before.

The jquery method $('FIELDREFERENCE') finds all elements on the form and returns a list of them. When you apply the .click listener method you are only applying it to the elements in the list.

To resolve this you will need to clear the listeners and re-assign them after each lookup. IE:

 

$(document).on("lookupcomplete", ResetClickListeners);

function ResetClickListeners(){

//Remove all current listeners (so that you do not double execute on click)
$('FIELDREFERENCE').off();

//Your original code in your screenshot goes here

}

 

0 0
replied on January 6, 2021

That did it.  Thank you so much for your help!

0 0

Replies

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

Sign in to reply to this post.