 
     if confirm('Are you sure you want to save?')
       if ExerciseStore.isNew(id)
-        ExerciseStore.on 'created', @redirect
+        ExerciseStore.once 'created', @loadExercise
+
         ExerciseActions.create(id, ExerciseStore.get(id))
       else
         ExerciseActions.save(id)
+
+  onNewBlank: (ev) ->
+    ev.preventDefault()
+    if @canResetPage('Are you sure you want create a blank Exercise?  You will lose all unsaved changes')
+      window.history.pushState({}, "Exercise Editor", "/exercises/new")
+      @addNew()
+
+  onReset: (ev) ->
+    ev.preventDefault()
+    if @canResetPage('Are you sure you want reset editing?  You will lose all unsaved changes')
+      window.history.pushState({}, "Exercise Editor", "/exercises/")
+      @replaceState({})
+
+  canResetPage: (msg) ->
+    not @state.exerciseId or
+      not ExerciseStore.isChanged(@state.exerciseId) or
+      confirm(msg)
+
 
   render: ->
     id = @state.exerciseId

    ExerciseActions.loaded(template, id)
    @setState({exerciseId: id })

  loadExercise: ->
    exerciseId = @props.exerciseId or this.refs.exerciseId.getDOMNode().value
    @setState({exerciseId})
    ExerciseActions.load(exerciseId)

  onFindKeyPress: (ev) ->
    return unless ev.key is 'Enter'
    @loadExercise()
    ev.preventDefault()

  renderExerciseOrLoad: ->

        <input type="text" className="form-control" onKeyPress={@onFindKeyPress}
          ref="exerciseId" placeholder="Exercise ID"/>
        <span className="input-group-btn">
          <button className="btn btn-default" type="button" onClick={@onFindExercise}>Load</button>
        </span>
      </div>

