mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Preventing incorrectly shown unload alert
issue #1327 - IE9 fires an unload when using Backbone.history.navigate which meant the alert always got shown on first save when the url changes from from /editor/ to /editor/id. Not sure if other browsers do this, but this workaround fixes it
This commit is contained in:
parent
3fd3102486
commit
2c3de67062
1 changed files with 8 additions and 3 deletions
|
@ -100,9 +100,6 @@
|
|||
self.updatePost();
|
||||
});
|
||||
this.listenTo(this.model, 'change:status', this.render);
|
||||
this.listenTo(this.model, 'change:id', function (m) {
|
||||
Backbone.history.navigate('/editor/' + m.id + '/');
|
||||
});
|
||||
},
|
||||
|
||||
toggleStatus: function () {
|
||||
|
@ -279,6 +276,7 @@
|
|||
Ghost.Views.Editor = Ghost.View.extend({
|
||||
|
||||
initialize: function () {
|
||||
var self = this;
|
||||
|
||||
// Add the container view for the Publish Bar
|
||||
this.addSubview(new PublishBar({el: "#publish-bar", model: this.model})).render();
|
||||
|
@ -287,6 +285,13 @@
|
|||
this.$('#entry-markdown').text(this.model.get('markdown'));
|
||||
|
||||
this.listenTo(this.model, 'change:title', this.renderTitle);
|
||||
this.listenTo(this.model, 'change:id', function (m) {
|
||||
// This is a special case for browsers which fire an unload event when using navigate. The id change
|
||||
// happens before the save success and can cause the unload alert to appear incorrectly on first save
|
||||
// The id only changes in the event that the save has been successful, so this workaround is safes
|
||||
self.setEditorDirty(false);
|
||||
Backbone.history.navigate('/editor/' + m.id + '/');
|
||||
});
|
||||
|
||||
this.initMarkdown();
|
||||
this.renderPreview();
|
||||
|
|
Loading…
Add table
Reference in a new issue