jQuery DatePicker在新添加的行上不起作用 [英] jQuery DatePicker not working on newly added row

查看:119
本文介绍了jQuery DatePicker在新添加的行上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个呈现为表格的gridview.我有一个添加"按钮,然后单击它,它将在表中创建一个新行.行的创建是使用jQuery中的"clone(true)"方法完成的.克隆的行是隐藏在gridview中的虚拟行.我已经为文本框分配了jQuery DatePicker.对于现有行,它工作正常.但是,当我单击"DatePicker"文本框作为新添加的行时,它没有打开.它将为现有行打开.可能是什么问题?

I've got a gridview that renders as a table. I have an "Add" button and clicking on that, it will create a new row in the table. The row creation is done using "clone(true)" method in jQuery. The cloned row is a dummy row which is hidden in the gridview. I've assigned jQuery DatePicker for a TextBox. It works fine for the existing row. But when I click the DatePicker textbox for newly added row, it doesn't open. It opens for the existing row. What might be the problem?

我的代码如下:

$("input[name $= 'txtDateOrdered']").datepicker({

        showButtonPanel     :   true
    ,   showOn              :   'button'
    ,   buttonImageOnly     :   true
    ,   buttonImage         :   '../../Image/calendar.gif'
});

推荐答案

很难看到您的代码,但是..

Hard to tell with out seeing your code but..

这可能是由于在页面加载时调用了用于将datepicker分配给输入的jquery.因此,当您克隆输入时,新克隆的输入没有连接到日期选择器(因为页面加载时不存在该日期选择器).

This is probably due to the jquery used to assign the datepicker to the input is called on page load. Hence when you clone the input the newly cloned input doesn't have the datepicker hooked up to it (since it didn't exist on page load).

在调用clone方法之后,您需要将日期选择器连接到新输入.

You will need to hook up the datepicker to the new input after you call the clone method.

这篇关于jQuery DatePicker在新添加的行上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆