Skip to content

Global callbacks #170

Closed
Closed
@elado

Description

@elado

Would be really helpful to track model hooks globally.

Let's say I have a list of categories to choose from, and on a different place on the screen user can delete categories. When they delete the selected category, I want to reset the scope variable.

scope.select = function (category) {
  scope.selectedCategory = category
};

Category.on('before:destroy', function (attrs) {
  if (scope.selectedCategory && scope.selectedCategory.id == attrs.id) {
    scope.selectedCategory = null;
  }
});

Another use case would be to update counters on delete/create.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions