Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kellyselden/ember-cli-dirty-confirm

A dirty model route transition aborter
https://github.com/kellyselden/ember-cli-dirty-confirm

Last synced: 16 days ago
JSON representation

A dirty model route transition aborter

Awesome Lists containing this project

README

        

#ember-cli-dirty-confirm

[![npm version](https://badge.fury.io/js/ember-cli-dirty-confirm.svg)](https://badge.fury.io/js/ember-cli-dirty-confirm)
[![Build Status](https://travis-ci.org/kellyselden/ember-cli-dirty-confirm.svg)](https://travis-ci.org/kellyselden/ember-cli-dirty-confirm)
[![Code Climate](https://codeclimate.com/github/kellyselden/ember-cli-dirty-confirm/badges/gpa.svg)](https://codeclimate.com/github/kellyselden/ember-cli-dirty-confirm)

A dirty model route transition aborter. It will show a confirm dialog giving you a chance to cancel a route change. If you agree, it will rollback your model.

##Usage

```
ember install ember-cli-dirty-confirm
```

```js
import DirtyConfirmRouteMixin from 'ember-cli-dirty-confirm/mixins/dirty-confirm-route';

export default Ember.Route.extend(DirtyConfirmRouteMixin, {
// optional, the default message is "Leaving this page will lose your changes. Are you sure?"
dirtyMessage: "Please don't go!",
// optional, temporarily disable the message
isDirtyConfirmEnabled: false
});
```

It also exposes an action called `toggleDirtyConfirm`, so you can toggle off from outside the route.