From 6d47d4854ed8130801a44321b9879a3050f83b6e Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Mon, 13 May 2013 16:04:07 -0400 Subject: [PATCH] Don't reload the page when auto close time is changed --- .../discourse/views/modal/edit_topic_auto_close_view.js | 3 ++- app/assets/javascripts/discourse/views/topic_closing_view.js | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/views/modal/edit_topic_auto_close_view.js b/app/assets/javascripts/discourse/views/modal/edit_topic_auto_close_view.js index db903fd8a3c..2fc31dadac4 100644 --- a/app/assets/javascripts/discourse/views/modal/edit_topic_auto_close_view.js +++ b/app/assets/javascripts/discourse/views/modal/edit_topic_auto_close_view.js @@ -29,13 +29,14 @@ Discourse.EditTopicAutoCloseView = Discourse.ModalBodyView.extend({ }, setAutoClose: function(days) { + var view = this; Discourse.ajax({ url: "/t/" + this.get('topic.id') + "/autoclose", type: 'PUT', dataType: 'json', data: { auto_close_days: days > 0 ? days : null } }).then(function(){ - window.location.reload(); + view.get('topic').set('auto_close_at', Date.create(days + ' days from now').toJSON()); }, function (error) { bootbox.alert(Em.String.i18n('generic_error')); }); diff --git a/app/assets/javascripts/discourse/views/topic_closing_view.js b/app/assets/javascripts/discourse/views/topic_closing_view.js index 3a566af759f..229b36fc7ef 100644 --- a/app/assets/javascripts/discourse/views/topic_closing_view.js +++ b/app/assets/javascripts/discourse/views/topic_closing_view.js @@ -11,6 +11,10 @@ Discourse.TopicClosingView = Discourse.View.extend({ elementId: 'topic-closing-info', templateName: 'topic_closing', + contentChanged: function() { + this.rerender(); + }.observes('topic.auto_close_at'), + render: function(buffer) { if (!this.present('topic.auto_close_at')) return;