Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/422.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 回发后重新申请所选内容_Javascript_Jquery_Jquery Ui_Jquery Chosen - Fatal编程技术网

Javascript 回发后重新申请所选内容

Javascript 回发后重新申请所选内容,javascript,jquery,jquery-ui,jquery-chosen,Javascript,Jquery,Jquery Ui,Jquery Chosen,我正在开发一个ASP.NET网站。我使用的是选中的jQuery下拉列表。它工作得很好。这是密码 <script type="text/javascript"> $(".chzn-select").chosen(); $(".chzn-select-deselect").chosen({ allow_single_deselect: true }); </script> $(“.chzn select”).select(); $(“.chzn se

我正在开发一个ASP.NET网站。我使用的是选中的jQuery下拉列表。它工作得很好。这是密码

<script type="text/javascript"> 
    $(".chzn-select").chosen(); 
    $(".chzn-select-deselect").chosen({ allow_single_deselect: true }); 
</script>

$(“.chzn select”).select();
$(“.chzn select deselect”).selected({allow_single_deselect:true});
在我添加UpdatePanel后,回发时,dropdownlist不再工作。(恢复到标准的dropdownlist。)我研究了这个问题,并根据我的研究编写了这段代码,但它不起作用

<script src="https://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
<script>
  alert("1");

  $(".chzn-select").chosen(); 
  $(".chzn-select-deselect").chosen({ allow_single_deselect: true }); 

  $(document).ready(function() {
      alert("2");
      // bind your jQuery events here initially
      $(".chzn-select").chosen(); 
      $(".chzn-select-deselect").chosen({ allow_single_deselect: true }); 
      alert("3");
  });

  var prm = Sys.WebForms.PageRequestManager.getInstance();

  prm.add_endRequest(function() {
      alert("4");
      // re-bind your jQuery events here
      $(".chzn-select").chosen(); 
      $(".chzn-select-deselect").chosen({ allow_single_deselect: true }); 
      alert("5");
  });

  alert("6");
</script>

警报(“1”);
$(“.chzn select”).select();
$(“.chzn select deselect”).selected({allow_single_deselect:true});
$(文档).ready(函数(){
警报(“2”);
//首先在这里绑定jQuery事件
$(“.chzn select”).select();
$(“.chzn select deselect”).selected({allow_single_deselect:true});
警报(“3”);
});
var prm=Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(函数(){
警报(“4”);
//在这里重新绑定jQuery事件
$(“.chzn select”).select();
$(“.chzn select deselect”).selected({allow_single_deselect:true});
警报(“5”);
});
警报(“6”);
请不要笑。正如您所看到的,我没有编写太多jQuery/js。哈哈:)


基本上,我试图用上面的代码重新应用所选的效果。但是,现在,它甚至没有在页面的初始加载中应用该效果。你能帮我解决这个问题吗?谢谢

1-首先在函数中添加js脚本

<script type="text/javascript"> 
        function ChosenDropdown() {
            $(".chzn-select").chosen();
            $(".chzn-select").chosen({ allow_single_deselect: true }); 
        }

    </script>
仅此而已,, 问候

protected void Page_Load(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "ChosenD", "ChosenDropdown()", true);

    }