Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In that case rendering can be fully customized and overwritten in the afterRender method.

isEmpty()

widget.isEmpty(/* no arguments */)

This should return true if the widget does not have any data to display. The default implementation uses this.collection.size() and returns true if the size is 0. When creating a widget from a facet collection, that is usually not the desired behaviour. In those cases, isEmpty can be overwritten.

As a lot of the processing of a widget may be needed to determine whether any data is to be displayed, widgets sometimes end up caching the result of that in the isEmpty method. The following is an example from a D3 widget:

Code Block
languagejs
isEmpty: function () {
    var squirroData = this.collection.indexed.$item_created_at.values;

    this.d3_data = d3.nest()
         …
         .map(squirroData);

    return this.d3_data.size() === 0;
},

Interaction

Squirro Widgets provide interaction by subscribing events to its DOM elements and handling them. All of these events fall into the interaction stage.

...