Javascript Datepicker onClose事件用作后台网格编辑器时未触发
我在网上搜索了一下,找不到任何关于这个问题的线索。这是我的片段Javascript Datepicker onClose事件用作后台网格编辑器时未触发,javascript,jquery,backbone.js,underscore.js,backgrid,Javascript,Jquery,Backbone.js,Underscore.js,Backgrid,我在网上搜索了一下,找不到任何关于这个问题的线索。这是我的片段 Backgrid.CustomDateCell = Backgrid.DateCell.extend({ editor: Backgrid.InputCellEditor.extend({ attributes: { type: "text" }, events: {}, initialize: function(){
Backgrid.CustomDateCell = Backgrid.DateCell.extend({
editor: Backgrid.InputCellEditor.extend({
attributes: {
type: "text"
},
events: {},
initialize: function(){
Backgrid.InputCellEditor.prototype.initialize.apply(this, arguments);
var _input = this;
$(this.el).prop('readonly', true);
$(this.el).datepicker({
autoclose: true,
todayHighlight: true,
format: "mm/dd/yyyy",
viewMode: "months",
minViewMode: "months",
onClose: function(dateText, inst){
var command = new Backgrid.Command({});
_input.model.set(_input.column.get("name"), dateText);
_input.model.trigger("backgrid:edited", _input.model, _input.column, command);
command = _input = null;
}
});
}
})
});
所以基本上,我想要的是触发backgrid:backgrid单元模型的编辑。但我似乎错过了一些东西。永远不会调用onClose事件,并且控制台中不会显示任何错误。我也尝试了onSelect事件,但结果相同
提前感谢如评论中所述: 这是一个引导数据采集器,因此
onClose
不是有效的选项。将侦听器附加到hide
事件:
$(this.el).datepicker({
autoclose: true,
todayHighlight: true,
format: "mm/dd/yyyy",
viewMode: "months",
minViewMode: "months"
});
$(this.el).on("hide", function(e) {
var command = new Backgrid.Command({});
_input.model.set(_input.column.get("name"), e.date);
_input.model.trigger("backgrid:edited", _input.model, _input.column, command);
command = _input = null;
});
e.date
应该为您提供相当于dateText
这是什么日期选择器viewMode
和autoclose
看起来像引导选项,但是onClose
是一个jqueryui选项,它是一个引导日期选择器。我忽略了这个。谢谢你的提醒。非常感谢你的帮助。现在触发了。所选日期仍然存在问题,因为它始终显示1970年1月。