Skip to content

Commit 8d259f3

Browse files
committed
Use event delegation for option delete buttons on manage attribute screen
1 parent 5cd7a90 commit 8d259f3

File tree

1 file changed

+5
-4
lines changed
  • app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute

1 file changed

+5
-4
lines changed

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/options.phtml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ require([
100100
if (isNewOption && !this.isReadOnly) {
101101
this.enableNewOptionDeleteButton(data.id);
102102
}
103-
this.bindRemoveButton(data.id);
104103
this.itemCount++;
105104
this.totalItems++;
106105
this.updateItemsCountField();
@@ -139,14 +138,16 @@ require([
139138
button.removeClassName('disabled');
140139
});
141140
},
142-
bindRemoveButton: function(id) {
143-
$('delete_button_' + id).observe('click', this.remove.bind(this));
144-
}
145141
};
146142

147143
if ($('add_new_option_button')) {
148144
Event.observe('add_new_option_button', 'click', attributeOption.add.bind(attributeOption));
149145
}
146+
147+
$('manage-options-panel').on('click', '.delete-option', function(event, element) {
148+
attributeOption.remove(event);
149+
});
150+
150151
<?php foreach ($block->getOptionValues() as $_value): ?>
151152
attributeOption.add(<?php echo $_value->toJson() ?>);
152153
<?php endforeach; ?>

0 commit comments

Comments
 (0)