diff --git a/public/src/client/category/tools.js b/public/src/client/category/tools.js index 544ab315813d..ccd6f8fedc2b 100644 --- a/public/src/client/category/tools.js +++ b/public/src/client/category/tools.js @@ -113,8 +113,15 @@ define('forum/category/tools', [ }); components.get('topic/merge').on('click', function () { + var tids = topicSelect.getSelectedTids(); require(['forum/topic/merge'], function (merge) { - merge.init(); + merge.init(function () { + if (tids.length) { + tids.forEach(function (tid) { + merge.addTopic(tid); + }); + } + }); }); }); diff --git a/public/src/client/topic/merge.js b/public/src/client/topic/merge.js index c04ddb021915..3a1119a29cf3 100644 --- a/public/src/client/topic/merge.js +++ b/public/src/client/topic/merge.js @@ -22,7 +22,7 @@ define('forum/topic/merge', function () { modal.find('.close,#merge_topics_cancel').on('click', closeModal); - $('#content').on('click', '[component="category"] [component="category/topic"] a', onTopicClicked); + $('#content').on('click', '[component="topic/select"]', onTopicClicked); showTopicsSelected(); @@ -69,6 +69,9 @@ define('forum/topic/merge', function () { }; function onTopicClicked(ev) { + if (!modal) { + return; + } var tid = $(this).parents('[component="category/topic"]').attr('data-tid'); Merge.addTopic(tid); @@ -98,6 +101,9 @@ define('forum/topic/merge', function () { } function showTopicsSelected() { + if (!modal) { + return; + } var tids = Object.keys(selectedTids); tids.sort(function (a, b) { return a - b; @@ -134,7 +140,7 @@ define('forum/topic/merge', function () { modal = null; } selectedTids = {}; - $('#content').off('click', '[component="category"] [component="category/topic"] a', onTopicClicked); + $('#content').off('click', '[component="topic/select"]', onTopicClicked); } return Merge;