是否可以将 contentEditable 与 jQuery DatePicker 一起使用?

2024-05-03

我正在寻找一种将 contentEditable 与 jQuery DatePicker 一起使用的方法。我如何在可编辑表格上使用它?

我在这里找到了一个答案:http://www.sencha.com/forum/showthread.php?229598-Looking-to-enable-contenteditable-true-for-custom-input-type http://www.sencha.com/forum/showthread.php?229598-Looking-to-enable-contenteditable-true-for-custom-input-type

这就是我尝试使用上面链接中给出的示例执行的操作。

HTML 代码:

<td>
    <div class='date' contenteditable='false'>2014-04-05</span>
    <input type='hidden' class='datepicker' />
</td>

JavaScript 代码:

$(".datepicker").datepicker({
    dateFormat: 'yyyy-mm-dd',
    showOn: "button",
    buttonImage: "images/calendar.gif",
    buttonImageOnly: true,
    onClose: function(dateText, inst) {
        $(this).parent().find("[contenteditable=true]").focus().html(dateText).blur();
    }
});

但这个方法对我不起作用。

附加信息:我正在使用 bootstrap 和 jquery-tablesorter。


我通过以下步骤为自己制作:

使用日期选择器的隐藏输入,与 contenteditable div 一起使用:

<div class="holder">
    <input name="date" class="datepicker-input" type="hidden" />
    <div class="date" contentEditable="true"></div>
</div>

使用以下 jQuery:

// Binds the hidden input to be used as datepicker.
$('.datepicker-input').datepicker({
    dateFormat: 'dd-mm-yy',
    onClose: function(dateText, inst) {
        // When the date is selected, copy the value in the content editable div.
        // If you don't need to do anything on the blur or focus event of the content editable div, you don't need to trigger them as I do in the line below.
        $(this).parent().find('.date').focus().html(dateText).blur();
    }
});
// Shows the datepicker when clicking on the content editable div
$('.date').click(function() {
    // Triggering the focus event of the hidden input, the datepicker will come up.
    $(this).parent().find('.datepicker-input').focus();
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

是否可以将 contentEditable 与 jQuery DatePicker 一起使用? 的相关文章

随机推荐

  • 如何将大型 JSON 对象直接序列化到 HttpResponseMessage 流?

    有没有办法将大型 JSON 对象直接流式传输到 HttpResponseMessage 流 这是我现有的代码 Dictionary
  • 使用 TypeScript 中的类型导入节点和 Express

    我正在尝试在 Visual Studio Code 中设置 TypeScript Express node 应用程序 如下所示微软指南 https code visualstudio com docs runtimes nodejs typ
  • 需要重定向 .NET 应用程序的帮助

    我正在尝试让 vscode 启用统一的 c 代码完成 如下this https code visualstudio com docs other unity指南显示 我曾有一个problem https stackoverflow com
  • ECLIPSE:无法下载新软件,停留在“待处理...”状态

    使用 Eclipse 3 7 Indigo 我知道有类似的问题 顺便说一下 已经过时了 但没有一个可以解决我的问题 我转到帮助 gt 安装新软件 gt 使用 并选择 靛蓝 http download eclipse org releases
  • 如何在vba中刷新/加载Excel中的RTD Bloomberg函数(BDH)

    我想知道 VBA 代码中是否有办法强制 Bloomberg 函数 在电子表格中 更新其值 任何 BDH 函数 目标开发人员面临类似问题 拥有彭博终端 我尝试过什么 Application RTD RefreshData Applicatio
  • 如何从 tcl 列表中删除空元素

    你好 我有以下清单 设置 qprList 12345 12345
  • 如何有条件地使用新的 Cocoa API

    苹果在 10 6 中添加了 NSPropertyListSerialization dataWithPropertyList format options error 并标记较旧的 NSPropertyListSerialization d
  • 如何使用 PDB 文件

    我听说使用 PDB 文件可以帮助诊断崩溃发生的位置 My basic理解是你给 Visual Studio 源文件 pdb 文件和崩溃信息 来自 Dr Watson 有人可以解释一下这一切是如何运作的 涉及什么吗 谢谢你 PDB 文件将程序
  • Cakephp:将 AppController 抽象到另一个层次,可能吗?

    我想知道是否可以在 AppController 和我的应用程序的其他控制器之间添加另一个抽象控制器 这样我的控制器 例如UsersController 扩展了 SecureController SecureController 扩展了 Ap
  • PHP 矩阵的逆矩阵

    I saw 这个问题 https stackoverflow com questions 211160 python inverse of a matrix 并弹出这个想法 PHP 有没有一种有效的方法来做到这一点 EDIT 最好有演示 你
  • 如何在 makefile 中针对特定目标使用 include 指令

    我只想将 include 指令用于特定目标 当不需要目标时 我不想运行其他 makefile 因为这意味着 makefile 是不必要生成的 那么有没有一种方法可以有条件地使用 include 指令 该指令以目标为条件 或者以某种方式使 i
  • 在 portlet 中使用 json 对象响应 http 请求

    我是liferay portlet 开发的初学者 我正在开发一个portlet 它接收http get 请求 处理一些信息 然后必须返回一个json 对象 我的问题是我的 portlet 发送整个 html 页面而不仅仅是 json 对象
  • Visual Studio 2010 是否允许您编辑图标?

    当我在 Visual Studio 2010 专业版 中双击 ico 文件时 它会打开看起来像图标编辑器的内容 看起来应该很容易从左侧选择颜色并编辑像素 但我的鼠标是一个放大镜图标 左键单击 右键单击 他们所做的只是切换图标的缩放 我不知道
  • 返回元组的第一个元素

    假设我创建一个将两个整数相加的函数 def addInt a Int b Int Int Int val x a b x 2 我回来了 result 2 故意为了这个问题 现在我想创建一个仅返回 x 的变量 val result addIn
  • python中跨模块和线程的全局变量

    我有一个配置文件 config py 它包含一个全局变量 即在 config py 中我有 5 是默认值 config py globalVar 5 现在 在模块 run py 中 我设置全局变量 然后调用打印函数 run py impor
  • 将数据从意图服务传递到活动

    我有一个广播接收器 正在调用intentservice 我想将intentservice中收到的数据发送到一个活动 String s extras getString Notice 我想将此收到的字符串发送到一个新活动 Override p
  • 比较中单引号与双引号的意义是什么? [复制]

    这个问题在这里已经有答案了 这会返回一个错误 return arg 0 arg 1 true false 错误 ISO C 禁止指针和整数之间的比较 然而 这并不 return arg 0 arg 1 true false 有什么区别 an
  • FlatBuffers:写入和读取二进制文件?

    我对 C 和 Google 中的文件流有基本了解平面缓冲区 http google github io flatbuffers Schema文件非常简单 也是创建一个缓冲区并读取 来自缓冲区指针 我不明白的是如何将多个缓冲区保存到一个二进制
  • Firebase持久化,清除Firebase缓存

    我的应用程序使用 Firebase 来同步和恢复数据 我用setValue withCompletionBlock 插入 更新和删除 Firebase 对象的方法 每当有 CoreData 保存时就会调用此方法 从而将我的所有本地更改同步到
  • 是否可以将 contentEditable 与 jQuery DatePicker 一起使用?

    我正在寻找一种将 contentEditable 与 jQuery DatePicker 一起使用的方法 我如何在可编辑表格上使用它 我在这里找到了一个答案 http www sencha com forum showthread php