Pharaonic / livewire-select2

Simple way to handle the Select2 for livewire components.
https://pharaonic.io/packages/livewire/select2
MIT License
37 stars 11 forks source link

Nested Dropdown #4

Closed masadi closed 2 years ago

masadi commented 2 years ago

How to use this repo for nested dropdown like selecting province then city and so on?

Thanks

MoamenEltouny commented 2 years ago

@masadi do you mean optgroup ?

masadi commented 2 years ago

@MoamenEltouny like this http://jsfiddle.net/greglockwood/T7LJY/3

MoamenEltouny commented 2 years ago

@masadi i don't think it's supported in Select2 Plugin at all .. but i believe that you can create it with livewire itself it's not related to our package

masadi commented 2 years ago

@MoamenEltouny here is another example using laravel 8 and ajax http://ilmukita.org/laravel-8-membuat-dynamic-dependent-dropdown-menggunakan-select2/

masadi commented 2 years ago

@MoamenEltouny SOLVED

window.addEventListener('component_updated', event => {
        $.each(event.detail.data_array, function (i, item) {
            $('#sub_select').append($('<option>', { 
                value: item.value,
                text : item.text
            }));
        });
    })