How to use Select2 in main search problem?

This topic contains 12 replies, has 5 voices, and was last updated by  Piotr Musiaka 4 years, 10 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #494959

    Piotr Musiaka
    Expired Member
    Post count: 18

    Hello,
    I have a problem using select2. I would like to use it in all select fields in search widget and add listing page. The problem occurs in the CPT section which causes reload of other related fields. At the time of change to another CPT select2 don’t reinit.

    Where I can find a function that is responsible for that.

    #495016

    Alex Rollin
    Moderator
    Post count: 27815

    I will flag your question for the developers, thanks for your patience while they get back to you about that.

    #495096

    Naveen Giri
    Moderator
    Post count: 1559

    Hi,

    if you are customising select2 functionality in Geodirectory. You can explore select2 here https://select2.org/getting-started/basic-usage

    or share the site details with login credentials and more information.
    so I can check the issue.

    #495162

    Piotr Musiaka
    Expired Member
    Post count: 18

    Hello, yes it works, but when you change CPT select field it restart, and select2 not reinit.

    Example – https://nearestbrewery.com/

    #495303

    Kiran
    Moderator
    Post count: 7069

    Hello Piotr,

    Please add css class “geodir-select” to select input. Adding that class will render select input as a select2.

    Switching CPT uses ajax request to show fields for switched CPT. To work select2 in ajax request use

    jQuery("select.geodir-select").trigger('geodir-select-init');

    . in the search form template.

    How you rendered select2 in search form?

    Kiran

    #495409

    Piotr Musiaka
    Expired Member
    Post count: 18

    Helo Kiran

    This is what i do in js:

    jQuery(‘select’).select2();

    How to add “geodir-select” in all selects fields – via js?
    jQuery(‘select’).addClass(‘geodir-select’);
    Better is add this class in pure html.

    I need gd search form and add listing functions in supreme theme functions.php to menage this or?

    How to really menage this?

    #495415

    Piotr Musiaka
    Expired Member
    Post count: 18

    Ok i done that, but this is hacking, i change core and plugin to make this work, is there a better option to do this?

    #495433

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    This is a theme issue, i have alerted the developer and given him the fix, if you need it before the next release then use this JS:

    jQuery("body").on("geodir_setup_search_form", function($form){
    					 jQuery('select').select2();
    				});

    Stiofan

    #495434

    Piotr Musiaka
    Expired Member
    Post count: 18

    Hello Stiofan,
    Where to add this code?
    Best

    #495436

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    There are many different ways to do it, but if i have to tell you then you might be better waiting for the update from the theme author so you don’t break things unintentionally.

    Stiofan

    #495438

    Piotr Musiaka
    Expired Member
    Post count: 18

    Hello Stiofan,
    i make my own theme based on supreme and it is heavily modificated 🙂 So i need to know where put this code 🙂

    #495443

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    you could simply wrap it in some tags and put it in your theme footer.php

    Stiofan

    #495594

    Piotr Musiaka
    Expired Member
    Post count: 18

    Ok it working 🙂 thank You 🙂

Viewing 13 posts - 1 through 13 (of 13 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket