facultymatt / angular-unsavedChanges

angular-unsavedChanges
175 stars 81 forks source link

Ability to ignore a non-reset button (i.e. non-submit type Submit) #32

Open trnelson opened 9 years ago

trnelson commented 9 years ago

Matt,

Great plugin. Implementing in a project and having issues with the warning being triggered when submitting a form. My current submit button is not type="submit", and was hoping you might have a suggestion on how to ignore warning and allow the form to submit in this case. My button code is below:

<button class="btn btn-primary" ng-click="confirm()">Save</button>

Thanks!

trnelson commented 9 years ago

Just a follow up:

Adding type="submit" to a button actually does allow a regular button to work for this. So the following is valid:

<button class="btn btn-primary" type="submit" ng-click="confirm()">Save</button>

Though I'm not sure whether it's a semantically valid attribute for the button element. Would it be possible to include a directive, say something like unsaved-warning-allow or unsaved-warning-ignore (not sure what's best) to force a particular element to ignore the warning?

Thanks again!

mateatslc commented 9 years ago

I put unsaved-warning-clear on my button-looking <a> tags, works alright for me. Give it a shot.

awerlang commented 9 years ago

@trnelson That's strange. When unspecified, default value for button[type] is submit. There's must be a bug somewhere else.

I always use type=button. How are you handling form submission?