diff --git a/role_expire.js b/role_expire.js
index 582df8b..5c0b54f 100644
--- a/role_expire.js
+++ b/role_expire.js
@@ -14,8 +14,17 @@
     attach: function (context, settings) {
       $('input.role-expire-role-expiry', context).parent().hide();
 
-      $('#edit-roles input.form-checkbox', context).each(function() {
-        var textfieldId = this.id.replace("roles", "role-expire");
+      var $checkbox = $('#edit-roles input.form-checkbox', context);
+      if (!$checkbox.length) {
+        // Let Role delegation work properly.
+        $checkbox = $('#edit-roles-change input.form-checkbox', context);
+      }
+      $checkbox.each(function() {
+        var textfieldId = this.id;
+        // Let Role delegation work properly.
+        textfieldId = textfieldId.replace("roles-change", "role-expire");
+
+        textfieldId = textfieldId.replace("roles", "role-expire");
 
         // Move all expiry date fields under corresponding checkboxes
         $(this).parent().after($('#'+textfieldId).parent());
@@ -26,8 +35,12 @@
         }
       });
 
-      $('#edit-roles input.form-checkbox', context).click(function() {
-        var textfieldId = this.id.replace("roles", "role-expire");
+      $checkbox.click(function() {
+        var textfieldId = this.id;
+        // Let Role delegation work properly.
+        textfieldId = textfieldId.replace("roles-change", "role-expire");
+
+        textfieldId = textfieldId.replace("roles", "role-expire");
 
         // Toggle expiry date fields
         if ($(this).attr("checked")) {
@@ -40,4 +53,4 @@
     }
   }
 
-})(jQuery);
\ No newline at end of file
+})(jQuery);
