diff --git a/js/misc/tabledrag.js b/js/misc/tabledrag.js
index ac41c8f6bd1b9e80f67334a266acc1512e668bb7..184479081edf8764a0e8c1d569fc25b853eb9f55 100644
--- a/js/misc/tabledrag.js
+++ b/js/misc/tabledrag.js
@@ -173,13 +173,13 @@
     $table.find('> tr.draggable, > tbody > tr.draggable').each(function () { self.makeDraggable(this); });
 
     // Add a link before the table for users to show or hide weight columns.
-    var $button = $(Drupal.theme('btn-sm', {
+    self.$toggleWeightButton = $(Drupal.theme('btn-sm', {
       'class': ['tabledrag-toggle-weight'],
       title: Drupal.t('Re-order rows by numerical weight instead of dragging.'),
       'data-toggle': 'tooltip'
     }));
 
-    $button
+    self.$toggleWeightButton
       .on('click', $.proxy(function (e) {
         e.preventDefault();
         this.toggleColumns();
@@ -187,7 +187,7 @@
       .wrap('<div class="tabledrag-toggle-weight-wrapper"></div>')
       .parent()
     ;
-    $table.before($button);
+    $table.before(self.$toggleWeightButton);
 
     // Initialize the specified columns (for example, weight or parent columns)
     // to show or hide according to user preference. This aids accessibility
