diff --git a/include/staff/templates/thread-entries.tmpl.php b/include/staff/templates/thread-entries.tmpl.php
index b1e3a83bd155a3c0f58867a112a7c9ad33518b4e..a43e45ba274599914153f51563cda292f409437e 100644
--- a/include/staff/templates/thread-entries.tmpl.php
+++ b/include/staff/templates/thread-entries.tmpl.php
@@ -5,8 +5,8 @@ $events->rewind();
 $event = $events->current();
 $htmlId = $options['html-id'] ?: ('thread-'.$this->getId());
 ?>
-<div id="<?php echo $htmlId; ?>" data-thread-id="<?php echo $this->getId(); ?>">
-    <div id="thread-items">
+<div id="<?php echo $htmlId; ?>">
+    <div id="thread-items" data-thread-id="<?php echo $this->getId(); ?>">
     <?php
     if (count($entries)) {
         // Go through all the entries and bucket them by time frame
diff --git a/js/redactor-osticket.js b/js/redactor-osticket.js
index 3b8529754661338e6cbb07430e451161313ab99b..8f8c29da99da04f9a0aa1c9db7eae3389960e8b5 100644
--- a/js/redactor-osticket.js
+++ b/js/redactor-osticket.js
@@ -310,8 +310,8 @@ $(function() {
             options['plugins'].push('fullscreen');
         if (el.data('translateTag'))
             options['plugins'].push('translatable');
-        if ($('#ticket_thread[data-thread-id]').length)
-            options['imageManagerJson'] += '?threadId=' + $('#ticket_thread').data('threadId');
+        if ($('#thread-items[data-thread-id]').length)
+            options['imageManagerJson'] += '?threadId=' + $('#thread-items').data('threadId');
         getConfig().then(function(c) {
             if (c.lang && c.lang.toLowerCase() != 'en_us' &&
                     $.Redactor.opts.langs[c.short_lang])