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

Question

Question

Dropdown values (populated with lookup and javascript) disappear after page finishes loading

asked on March 29, 2019

I have a dropdown that populates via a lookup.  The value is two-part: a "friendly" name and a username, separated by a pipe '|' character.  Because we want the user to see the friendly name, but the system to see the username, we use the following javascript to separate the parts into "value" and "display" categories:

 

$(document).ready(function () {
      $('.choice-value-dropdown select').prop('disabled',true);
      
  $(document).on('lookupcomplete', function(event){
      $('.User_Select option').each(function(){
        let text = $(this).text().split('|');
        $(this).text(text[0]);
        $(this).val(text[1]);
      });

      $('.choice-value-dropdown select').prop('disabled',false);
  });
});

 

The script was working perfectly, and I frankly have no idea why it's not working now.  As I step through in the browser debugger, I can see it working properly; the username portion gets assigned as the value, the friendly name as the text.  At the completion of the javascript function, everything is looking good.  Yet, when I let the page finish loading, suddenly the "value" attribute in the html is empty.

 

We are using Laserfiche v10.4

 

I haven't been able to make heads or tails of this issue, here's hoping one of you clever folks out there has an answer!

0 0

Answer

SELECTED ANSWER
replied on April 1, 2019 Show version history

Ok, I think I've got it fixed.

We were using the lookupcomplete event, which is kind of unreliable. Once I changed it out to onloadlookupfinished it got better.

1 0
replied on April 1, 2019

That appeared to do the job!  Thanks Devin!

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.