Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Create a mixin for confirmation dialogs when working with long forms

Open
#1,569 1 comment 0 reactions 1 assignee View on GitHub

@snewcomer is already working on this.

Since Dec 9, 2017.

Assessment

This issue has not been assessed yet.

Description

Difficulty: Easy in progress Priority: Low Skill: Ember.js

Problem

We have a number of places where we ask a user to confirm before leaving the page. We could write a mixin to help clean up this logic.

export default Ember.Mixin.extend({;
  modelName: null,
  message: 'You will lose any unsaved information if you leave this page. Are you sure?',
  
  actions: {
    willTransition() {
      let modelName = get(this, 'modelName');
      if (isPresent(modelName)) {
         let model = get(this, modelName);
         if (get(modelName, 'isNew') {
           this._confirmTransition(transition, model);
         } 
      } else {
        this._confirmTransition(transition);
      }
    }
  },

  _confirmTransition(transition, model) {
    let message = get(this, 'message');
    if (window.confirm(message)) {
      if isPresent(model) {
        model.destroyRecord();
      }
    } else {
      transition.abort();
    }
  }
})
Dominant language
JavaScript
Stars
120
Forks
75
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from code-corps/code-corps-ember

All issues in code-corps/code-corps-ember

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.