Select2 ajax delay option

Support General Select2 ajax delay optionResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #18291
    Ryan LauritsenRyan Lauritsen
    Participant

    For select_advanced fields can we please have a way to set the ajax delay option for select2 via js_options for the field or a filter?

    https://select2.org/data-sources/ajax#rate-limiting-requests

    I've tried adding it to js_options but it's not working.

    array(
        'name' => 'Author',
        'id' => 'post_author',
        'type' => 'user',
        'field_type'  => 'select_advanced',
        'placeholder' => 'Select an Author',
        'query_args'  => array(
            'role' => 'my_custom_role',
            'number' => 10,
        ),
        'js_options' => array(
            'minimumInputLength' => 3, // Require this many characters before triggering the ajax request.
            'ajax' => array(
                'delay' => 10000, // Wait this many milliseconds before triggering the ajax request.
            ),
        ),
    ),
    #18298
    Anh TranAnh Tran
    Keymaster

    Hi Ryan, I've just fixed it here. Now your code will work.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.