【问题标题】:Bind jQuery DatePicker after partial update in ASP.Net MVC在 ASP.Net MVC 中部分更新后绑定 jQuery DatePicker
【发布时间】:2009-05-27 16:45:41
【问题描述】:

在我看来,我正在使用 Ajax 调用来动态显示表单以将新条目添加到列表中。成功添加条目后,列表将再次显示。

但是,在这种形式中,我有一个文本字段,用户需要在其中输入日期。我需要做什么才能将 jquery UI DatePicker 动态绑定到该字段?

【问题讨论】:

    标签: jquery asp.net-mvc jquery-ui-datepicker


    【解决方案1】:
    $('#textfield_id').live('ready', function(){ $(this).datepicker(); })
    

    不确定 datepicker 和 textfield 的确切名称,但这应该适用于使用此 id 添加到页面的任何文本字段,无论是否通过 ajax。

    【讨论】:

      【解决方案2】:

      在这里:jQuery live() failing with jQuery UI datepicker

      我发现这更有帮助:

      $('#textfield_id').live('click', function () {
                  $(this).datepicker('destroy').datepicker().focus();
              }); 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-07-14
        • 1970-01-01
        • 2013-07-27
        • 2012-02-29
        • 2012-04-21
        • 2011-07-24
        相关资源
        最近更新 更多