Multi-select Enhanced select – disable exact match

Home Forums Quform WordPress Multi-select Enhanced select – disable exact match

This topic is: resolved
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #35278
    amplastic
    Participant

    I have a mult-select field with “enable enhanced select” turned on. When I start typing into this field, options will only show if the search term is an exact match. However, I want options to come up without it exactly matching in same order as terms. How can I accomplish this?

    Attachments:
    You must be logged in to view attached files.
    #35284
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #35286
    amplastic
    Participant

    now it displays results it shouldn’t. it seems to be searching for the letters within the words i type? I want it to search for the exact words i type in but doesn’t have to be in the exact order that i type the words in

    • This reply was modified 1 year, 8 months ago by amplastic.
    • This reply was modified 1 year, 8 months ago by amplastic.
    Attachments:
    You must be logged in to view attached files.
    #35290
    amplastic
    Participant

    i got chatgpt to code it for me 🙂

    jQuery(function ($) {
    function containsAllWords(words, text) {
    for (var i = 0; i < words.length; i++) {
    if (text.toLowerCase().indexOf(words[i].toLowerCase()) === -1) {
    return false;
    }
    }
    return true;
    }

    $(‘.quform-field-multiselect-enhanced’).each(function () {
    var $select = $(this),
    options = $select.data(‘options’),
    config = {
    theme: ‘quform’,
    language: {
    noResults: function () {
    return options.noResultsFound;
    }
    },
    matcher: function(params, data) {
    // If there are no search terms, return all of the data
    if ($.trim(params.term) === ”) {
    return data;
    }

    // Do not display the item if there is no ‘text’ property
    if (typeof data.text === ‘undefined’) {
    return null;
    }

    // params.term should be the term that is used for searching
    // data.text is the text that is displayed for the data object
    var words = params.term.trim().toLowerCase().split(/\s+/);
    if (containsAllWords(words, data.text.toLowerCase())) {
    var modifiedData = $.extend({}, data, true);

    // You can return modified objects from here
    // This includes matching the children how you want in nested data sets
    return modifiedData;
    }

    // Return null if the term should not be displayed
    return null;
    }
    };

    if (Quform.isNonEmptyString(options.placeholder)) {
    config.placeholder = options.placeholder;
    }

    if (options.rtl) {
    config.dir = ‘rtl’;
    }

    $select.select2(‘destroy’).select2(config);
    });
    });

    #35294
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy