cartodb/doc/frontend/editor/js/conventions.md

21 lines
720 B
Markdown
Raw Normal View History

2020-06-15 10:58:47 +08:00
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](http://api.jquery.com/jQuery.ajax/#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:
```js
aDialogView
.bind('done', function() {
console.log('dialog is done :)');
this.collection.fetch();
.bind('fail', function(err) {
console.log('something failed :/');
// Do nothing for now
};
```