“设置”为 null 或不是对象(jquery ui datepicker)
我有一个通过简单模式弹出窗口显示的表单,其中一个表单元素是 jquery ui 日期选择器。如果您打开表单,选择一个日期,关闭模式,然后再次打开表单并尝试选择一个日期,我会收到帖子标题中的 JavaScript 错误 (IE8)。由于我目前正在工作,所以我还没有在其他浏览器上测试过它,但我需要在 IE8 上运行它。
引发此错误的代码示例可以在 http://jsbin.com/uzewi4/10
我不太擅长 javascript,但我假设 simplemodal 正在破坏或在关闭模式时做一些奇怪的事情,这会导致日期选择器中断。我有什么想法可以解决这个问题吗?
I've got a form that gets shown via a simplemodal popup and one of the form elements is a jquery ui datepicker. If you open the form, choose a date, close the modal, then open the form again and try and choose a date I get a javascript error (IE8) that's in the title of the post. I haven't tested it on other browsers as I am in work at the moment, but I need this working on IE8.
An example of the code that throws this error can be found at http://jsbin.com/uzewi4/10
I'm not very good at javascript, but I'm assuming simplemodal is destroying or doing something weird when you close the modal, which causes the datepicker to break. Any ideas how I can fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是简单模态。来自文档:
所以它会克隆元素,然后用克隆替换它们。显然
DatePicker
并不期望这种情况发生(可以理解)。非常奇怪的行为,但是添加
persist: true
使您的示例有效:http://jsbin. com/uzewi4/11
题外话:FWIW,jQuery UI 本身有一个非常好的 对话机制,包括模态...
It's SimpleModal. From the docs:
So it's cloning the elements, and then replacing them with clones. Clearly
DatePicker
isn't expecting that to happen (understandably).Very odd behavior, but adding
persist: true
makes your example work:http://jsbin.com/uzewi4/11
Off-topic: FWIW, jQuery UI itself has a perfectly nice dialog mechanism, including modality...