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

Question

Question

How to ensure or wait for lookup to refresh input field datalist when it is triggered by code

asked on February 15, 2017 Show version history

In the above form 'Airports' input field datalist is populated by lookup from a database table based on 'Travel Type' (Domestic or International). 

Problem is sometime when 'Travel Type' field option is changed 'Airports' datalist is not getting refreshed. For example in the above case I changed travel type from domestic to international but airports input field shows only value only with in domestic cities (Australia). Where as if I refresh the form and try again this it loaded correctly. So the issue is happening randomly.

Here is how lookup defined -

'Fly From Filter' is an hidden input field that holds value of Travel Type radio button (Domestic or International). Every time Travel Type changed 'Fly From Filter' field gets updated and in code I am triggering the change event on 'Fly From Filter' field expecting it to refresh lookup data.

        $('.hf-fly-from-filter input').val($('.travel-type input').val());
        $('.hf-fly-from-filter input').trigger('change');

But it is sometime working and sometimes not. Is there any way that I can ensure or wait for the lookup to refresh Airports datalist every time travel type option is changed. Appreciate any help on this.

 

 

0 0

Replies

replied on February 16, 2017 Show version history

What version of Forms are you running?  Because there were a lot of lookup improvements in the updates to 10.1.

0 0
replied on February 16, 2017

Laserfiche Forms Version 10.1.0.642

0 0
replied on February 17, 2017

Okay, looks like that's update 3.  So that isn't the issue...

0 0
replied on February 17, 2017

Am I right in understanding that you have FieldA triggering a lookup to populate FieldB which should then be triggering a lookup to populate FieldC, etc.?  

I've had issues with stacked lookups like this.

If I've misunderstood the situation, then this information won't help much.  But if it is the case, then maybe this could be useful:

1. I had a similar issue while in 10.1 update 3 - where a lookup was triggered off of a field that was being populated by another lookup, and it was not consistently triggering the change event of the first field and thus not consistently calling the trigger ('change') to kickoff the second lookip.  I ended up working around it by creating database views and stored procedures to eliminate a step in my process and reduce the number of lookups.  I don't know if that would work for you though.

2. Alternately, you may want to consider upgrading to version 10.2 because it added event listeners for lookupstarted and lookupcomplete (whereas 10.1 update 3 only has a listener for completion of lookups occurring with form load, onloadlookup).  If you were to upgrade to 10.2, the Javascript would be something like this (you would change the 'Field1' to whatever field is kicking off the very first lookup - this assumes it is #q1):

$(document).on("lookupcomplete", function (event) {
  if (event.triggerId == "Field1") {
    $('.hf-fly-from-filter input').val($('.travel-type input').val());
    $('.hf-fly-from-filter input').trigger('change');
  }
});

 

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

Sign in to reply to this post.