Question

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/

Was it helpful?

Solution

In the example from the dynatable website they manually call the afterProcess function the first time it runs. For your code that looks something like:

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

// call the first time manually
processingComplete();

If you want to see this in a fiddle, check here: http://jsfiddle.net/pDVvx/2/

In case you were interested the dynatable code I'm referring to is:

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

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

Best of luck!

OTHER TIPS

try adding a parameter to your callback function

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

function processingComplete(a)
{
 alert('foo');
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top