1

I'm trying to bind click event to dynatable generated, I've tried $('#my-final-table hr').on("click",function(){alert("foo");}); so I'm trying to bind it after loading data:

var jsondata=[
  {
    "band": "Weezer",
    "song": "El Scorcho"
  },
  {
    "band": "Chevelle",
    "song": "Family System"
  }
];
$('#my-final-table').dynatable({
  dataset: {
    records: jsondata
  }
})
.bind('dynatable:afterProcess', function(){alert('foo')});

But it doesn't work, no alert is shown after loading. JSFiddle:http://jsfiddle.net/maysamsh/pDVvx/

4

2 回答 2

2

在 dynatable 网站的示例中,他们afterProcess在第一次运行时手动调用该函数。对于您的代码,看起来像:

var processingComplete = function(){alert('foo')};
$('#my-final-table').dynatable({
  dataset: {
    records: jsondata
  }
}).bind('dynatable:afterProcess', processingComplete);

// call the first time manually
processingComplete();

如果你想在小提琴中看到这个,请在​​这里查看:http: //jsfiddle.net/pDVvx/2/

如果您对我所指的可动态代码感兴趣:

$table.dynatable({
  // settings & code here
}).bind('dynatable:afterProcess', updateChart);

// Run our updateChart function for the first time.
updateChart();

祝你好运!

于 2014-04-21T16:09:19.240 回答
0

尝试向回调函数添加参数

$('#my-final-table').dynatable({
   dataset: {
   records: jsondata
}
}).bind('dynatable:afterUpdate', processingComplete);

function processingComplete(a)
{
 alert('foo');
}
于 2014-11-27T23:08:30.907 回答