mercredi 16 décembre 2020

Select Filtration not working properly laravel and vuejs

I have price vehicle price addition page along with accessories to the vehicle,i have 2 select2 dropdown with filtering,when a user select vehicle model from 1st select2 dropdown,then the 2nd dropdown will show corresponding vehicle based on the selection of model,my problem when i select vehicle model the corresponding vehicle is not showing,it shows blank,when i select model name it will reach to the filtering function but it's not reaching to the function,there is no problem with API I am using Vuejs along with laravel Filter function

<script type="text/javascript">

        $(document).ready(function () {
        $('.js-example-basic-single').select2();
        });


        //Filter Varient
        $(document).ready(function ($) {
           
            $("#vmodel").change(function () {
               
                $.get("",
                    
                {
                    option: $(this).val()
                },

                function (data) {
                    console.log(data);
                    let varient = $('#varient');
                    varient.empty();
                    varient.find('option').remove().end().append(" <option value=''>Select Varient</option>");
                    $.each(data, function (key, value) {

                        varient.append($("<option></option>").attr('value', value['variant_id']).text(value['name']))
                    });
                });
            });
        });
</script>

Dropdown code

<div class="form-group">
    <label for="users">Vehicle Model</label>
    <select name="vmodel" id="vmodel"
    class="js-example-basic-single form-control"style="width: 80%;">
    <option selected>Select Vehicle Model</option>
    @foreach($vehicle as $vehicles)

    <option value=""></option>
    @endforeach
    </select>
    </div>
    <div class="form-group">
        <label for="users">VehicleVariant</label>
         <select name="varient" id="varient" class="js-example-basic-single form-control"
                   style="width: 80%;">
                                            
    </select>


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire