hernansartorio / jquery-nice-select

A lightweight jQuery plugin that replaces native select elements with customizable dropdowns.
http://jqueryniceselect.hernansartorio.com
957 stars 286 forks source link

option.append() doesn't work #84

Open lnovali opened 5 years ago

lnovali commented 5 years ago

Wonderfull plugin, but I have problems to create two select input depending each other (the second select should be populated when the user select a value in the first select input). My ajax function return (correctly) a list of option (for example: "" I use the append method on success success: function (data) { // alert( data ); <-- this alert works fine and show me the option list $('#cerca_dist').append(data); }

cerca_dist is the select input I'm trying to populate with ajax response

     <select id="cerca_dist" name="cerca_dist">
      </select>

where I'm wrong?

476344704 commented 5 years ago

$('#select_ID').niceSelect('update');

AndrewMarkUK commented 5 years ago

I have it working in a way you would like to. I generate the subsequent menu on the fly - but it does not matter...

$('#appointment_ui').append('select_menu'); $('select_menu').append(array).niceSelect();

This is with jquery.

Works beautiful, hope that helps!