Search code examples
jquerydrop-down-menuslimselect

2 fields SlimSelect - Single and Multi - with results from Json


I am using Slimselect to create my dropdowns, and I have two related fields, it is:

Single Select : "Aréa de atuação principal *" and Multi Select : "Outras áreas de atuação"

I am trying to hide one option from the second select (Outras áreas de atuação), the field that was selected earlier in the single select, I am already found it via Jquery, but for some reason I cant add a class or something... I can display the text value of the option, but it doesn't add the class...

Here is the form: https://www.nalei.com.br/cadastro-de-profissional/

You just need to select any option from the Single Select : "Aréa de atuação principal *" and it will enabled the multiselect, and display the value text of the second select in console.log

Here is the section which I trigger the select from the single select and get the same value text from the second (multi select), but now I need to hide it...

$('#area_de_atuacao_principal').change(function(){
            if($('#area_de_atuacao_principal').val() != '') {
                var area_de_atuacao_principal = $("#area_de_atuacao_principal").children("option").filter(":selected").text();
                //console.log(area_de_atuacao_principal);
                area_de_atuacao_outras.enable();

                var teste = $('#select_area_de_atuacao_outras > div > div.ss-content > div.ss-list > div:contains('+area_de_atuacao_principal+')').text();
                $('#select_area_de_atuacao_outras > div > div.ss-content > div.ss-list > div:contains('+area_de_atuacao_principal+')').addClass('teste');
                console.log(teste);
            }
        });

Could someone please tell me why the .addClass isn't working?


Solution

  • Finally found a solution rs.... I had to filter the json result removing the value from the first select (single select), and them load the second select (multi select) without the value of the first one...