使用来自 recline.js 的 SlickGrid 视图,我一直在尝试将单击事件绑定到一行,但没有成功。这很容易$('.slick-row').click(function() {...etc})
,但我希望使用骨干式视图来处理我的事件。似乎什么都没有开火。上下文似乎是正确的。有什么明显的我忽略了吗?
我的 HTML 容器:
<div id="mygrid" style="height: 400px"></div>
我的 JS:
$(function() {
var data = [
{id: 0, date: '2011-01-01', x: 1, y: 2, z: 3, country: 'DE', geo: {lat:52.56, lon:13.40} },
{id: 1, date: '2011-02-02', x: 2, y: 4, z: 24, country: 'UK', geo: {lat:54.97, lon:-1.60}},
{id: 2, date: '2011-03-03', x: 3, y: 6, z: 9, country: 'US', geo: {lat:40.00, lon:-75.5}},
{id: 3, date: '2011-04-04', x: 4, y: 8, z: 6, country: 'UK', geo: {lat:57.27, lon:-6.20}},
{id: 4, date: '2011-05-04', x: 5, y: 10, z: 15, country: 'UK', geo: {lat:51.58, lon:0}},
{id: 5, date: '2011-06-02', x: 6, y: 12, z: 18, country: 'DE', geo: {lat:51.04, lon:7.9}}
];
var dataset = new recline.Model.Dataset({
records: data
});
var $el = $('#mygrid');
var grid = new recline.View.SlickGrid({
model: dataset,
el: $el,
state: {
gridOptions: '',
},
// Click handler?
events: {
'click .slick-row': 'handleClick',
'click': 'handleClick',
},
handleClick: function(e) {
console.log('row clicked');
}
});
grid.visible = true;
grid.render();
});