在jQuery selectn select中的choosen(“ destroy”)无效

时间:2018-08-20 05:12:15

标签: jquery html dropdown

我在使用Jquery Chosen插件的表单中有很多选择元素,但我无法重置表单:

我已经引用了此链接,但对我没有帮助:

jQuery Chosen reset

我的代码是:

已更新

 $scope.share = function (share_data,type, doc_type) {
        // $('.userlist').chosen().destroy()
            $scope.sharedgroup = [];
            $scope.users_select = "";
            // $scope.sharetype = type;
            $scope.doc_type = doc_type; 
            $scope.shareid = share_data._id;
            console.log(share_data)
            $('#shareModal').modal('toggle');
        $scope.getclientshare(share_data);  
        // $(".userlist").val([]).trigger('chosen:updated')
        $scope.getfilterlist=function(){
         $http.post("/getuserslist", { 'users': 'list'}).then(function (response) {
            $scope.userlist = response.data
            $(".userlist").val('').trigger("chosen:updated");
            $timeout(function () {
               $(".userlist").chosen({ disable_search_threshold: 3 });
                $scope.page_loader = false;            
          });

         });  
        }
        $scope.getfilterlist();


    };

我做错了吗?

3 个答案:

答案 0 :(得分:2)

$(“。chosen-select”)。val('')。trigger(“ chosen:updated”);

请尝试此操作,它将在下拉菜单中设置默认值。

答案 1 :(得分:0)

tmp_conf

答案 2 :(得分:0)

请参见下面的代码

 $(".chzn-select").chosen();
$('a').click(function(){
    $(".chzn-select").val('').trigger("liszt:updated");
});​
相关问题