Сбросить и добавить новые данные в bootstrapDualListbox [закрыто]Php

Кемеровские программисты php общаются здесь
Гость
Сбросить и добавить новые данные в bootstrapDualListbox [закрыто]

Сообщение Гость »


In create.blade.php I have 2 select fields

First select field is to select a customer, second select field uses bootstrapDualListbox that displays all cars when create view is returned

I need when a customer has been selected to repopulate the bootstrapDualListbox with cars that only related to that customer

I get in console.log the new options data in json correctly when a customer is selected, the problem I'm facing is resetting the bootstrapDualListbox and repopulating it with the new data I got after customer selection

HTML:

@foreach($customer_cars $id => $customer_car) {{ $customer_car }} @endforeach JS:

$(document).ready(function () { $("#customer_id").on('change', function(){ var customer_id = this.value; console.log(customer_id) var customerUrl = "{{ route('admin.user-cars.byCustomer') }}/" + customer_id; $.ajax({ url: customerUrl, success: function(result){ var html = ''; result = jQuery.parseJSON(result); console.log(result); for(var key in result) { html += ''+result[key]+''; } console.log(html); $('.customer_cars_duallistbox').bootstrapDualListbox('refresh', true); $(".customer_cars_duallistbox").append(html); } }); }); }); Also tried

$("#customer_cars_duallistbox").html(html); $('#customer_cars_duallistbox').val(''); Nothing changes at all,

If I try appending the new customer filtered data to a select2 field it works fine, but how to correctly implement this for bootstrapDualListbox?

Any help appreciated.


Источник: https://stackoverflow.com/questions/781 ... uallistbox

Вернуться в «Php»