无法根据按钮的类别选择按钮
我希望我的 jQuery
日期选择器 (jQuery UI 1.8.13) 仅在单击“完成”按钮时生成报告。
onClose
事件不好,因为当我单击某处时也会触发该事件否则(不在日期选择器中),我只需要在按下“完成”按钮时生成报告。因此,我需要向“完成”按钮添加一个 onclick
回调。但是我找不到与“完成”按钮匹配的 jQuery
选择器。我已经尝试过 $('.ui-corner-all')
但这也会找到其他元素。 所以,我尝试了 $('.ui-priority-primary')
(因为据我所知,这是唯一具有这种样式的元素),但它与按钮不匹配......
- 我需要一个仅匹配“完成”按钮的选择器。
- 为什么
$('.ui-priority-primary')
不起作用?
请在此处找到示例代码。
更新 我使用这个日期选择器作为月份选择器,所以我没有要点击的日期。因此,正如我上面所说,我需要将回调放在“完成”按钮上,这一点很重要。
I want my jQuery
datepicker (jQuery UI 1.8.13) to generate a report only when I click the 'Done' button.
The onClose
event is not good because that is triggered also when I click somewhere else (not in the datepicker) and I need to generate the report only when the 'Done' button is pressed. Therefore I need to add an onclick
callback to the 'Done' button. However I can not find a jQuery
selector that will match the 'Done' button. I have tried the $('.ui-corner-all')
but that will also find other elements too.
So, I have tried $('.ui-priority-primary')
(because AFAIK this is the only element that has this style), but it does not match the button ...
- I need a selector that will only match that 'Done' button.
- Why is
$('.ui-priority-primary')
not working?
Please find the sample code here.
UPDATE I use a this datepicker as a monthpicker, so I do not have dates to click on. Therefore it is important that I need to put the callback on the 'Done' button as I have stated above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如何使用
onSelect
事件,该事件在选择日期:How about using the
onSelect
event which is triggered when a date is selected:就它不起作用而言,这是因为控件是在绑定发生后创建的。如果您使用委托,那么它将起作用。虽然我认为达林的答案可能是一个更好的解决方案,但我提供这个答案是因为它直接回答了你问题的“原因”。
http://jsfiddle.net/7ThB8/30/
As far as it not working, this is because the control is created after your binding takes place. If you use delegate then it will work. Although I think Darin's answer is probably a better solution, I am providing this as it directly answers the 'why' of your question.
http://jsfiddle.net/7ThB8/30/