See first Dataset basics tutorial for getting setup and initializing Dataset.

Listening for Events

Often you’ll want to listen to events on a Dataset and its associated objects. This is easy to do thanks to the use of Backbone model objects which have a standard set of events.

Here’s an example to illustrate:

function onChange() {
  $('.ex-events').append('Queried: ' + dataset.queryState.get('q') + '. Records matching: ' + dataset.recordCount);
  $('.ex-events').append('<br />');

dataset.records.bind('reset', onChange);

dataset.query({q: 'DE'});
dataset.query({q: 'UK'});
dataset.query({q: 'US'});

dataset.unbind('reset', onChange);

Here’s a summary of the main objects and their events: