Skip to content
Snippets Groups Projects
Commit 3b77b79f authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Hooks into the new form button and displays message if changes are pending.

parent 1da3644f
No related branches found
No related tags found
No related merge requests found
......@@ -179,8 +179,23 @@ var QfqNS = QfqNS || {};
/**
* @private
*/
n.QfqForm.prototype.handleNewClick = function () {
n.QfqForm.prototype.handleNewClick = function (event) {
event.preventDefault();
var anchorTarget = event.target.getAttribute("href");
this.lastButtonPress = "new";
if (this.form.getFormChanged()) {
var alert = new n.Alert("You have unsaved changes. Do you want to close?", "warning", "yesnosave");
var that = this;
alert.on('alert.save', function () {
that.form.submitTo(that.submitTo);
window.location = anchorTarget;
});
alert.on('alert.ok', function () {
window.location = anchorTarget;
});
alert.show();
}
n.Log.debug("new click");
};
......@@ -330,7 +345,7 @@ var QfqNS = QfqNS || {};
* @private
*/
n.QfqForm.prototype.getNewButton = function () {
return $("#new-button");
return $("#form-new-button");
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment