.focus() changing to first search field

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
bpmsolutions
User
Posts: 26

.focus() changing to first search field

Post by bpmsolutions »

I have a following situation:

  1. I'm reading ProductionOrder from the barcode printed on my label.
  2. In list page, I put code on the Startup script
    $(document).ready(function() {
    $("#x_ProductionOrder").focus();
    });
    $("#x_ProductionOrder") is listed as third Extended search field. Idea is that after load, focus is on this field so the barcode scanner can be used without manually pointing to field.
  3. After generation, behaviour is as follows:
    Form is loaded, focus is for few moments on field $("#x_ProductionOrder"), then changes to a first Extended search field (which is select2). Class of this first extended search field is select2 select2-container select2-container--bootstrap5 select2-container--focus.

Possible solutions:

  1. Change first Extended search field class? How to?
  2. Change field order ONLY on the searchbar / search page. How to?

bpmsolutions
User
Posts: 26

Post by bpmsolutions »

For now, I have solved this using delay, but looking for better solution.

    setTimeout(function() {
            $("#x_ProductionOrder").focus();
        }, 300); // Delay in milliseconds, adjust as needed

Post Reply