cartodb/doc/frontend/editor/js/conventions.md
2020-06-15 10:58:47 +08:00

720 B

This article describes conventions we defined for the JS code.

Backbone

Views

Event names

Use done and fail for event names, to be consistent with naming convention used in jqXHR objects (typically returned from a Backbone model/collection on an asynchronious operation. Typically used for dialogs, where the final operation and its outcome should have some implication in the UI (e.g. refresh list, hide/show some view etc.)

Example:

aDialogView
  .bind('done', function() {
    console.log('dialog is done :)');
    this.collection.fetch();
  .bind('fail', function(err) {
    console.log('something failed :/');
    // Do nothing for now
  };