How do I reset a jquery-chosen select option with jQuery?

前端 未结 21 760
一个人的身影
一个人的身影 2020-11-30 21:42

I have tried numerous things and nothing seems to be working.

I am using jQuery and Chosen plugin.

Methods I have tried:

var select = jQuery(         


        
21条回答
  •  心在旅途
    2020-11-30 22:27

    from above solutions, Nothing worked for me. This worked:

    $('#client_filter').html(' '); //this worked

    Why is that? :)

    $.ajax({ 
            type: 'POST', 
            url: xyz_ajax,
            dataType: "json",
            data : { csrfmiddlewaretoken: csrftoken,
                    instancess : selected_instances }, 
            success: function(response) { 
                //clear the client DD       
                $('#client_filter').val('').trigger('change') ; //not working
                $('#client_filter').val('').trigger('chosen:updated') ; //not working
                $('#client_filter').val('').trigger('liszt:updated') ; //not working
                 $('#client_filter').html(' '); //this worked
                 jQuery.each(response, function(index, item) {
                      $('#client_filter').append('');
                    });                 
               $('#client_filter').trigger("chosen:updated");
            }
          });
         } 
    

提交回复
热议问题