Skip to content

Commit 5cd7a90

Browse files
committed
Refactor bindRemoveButtons for improved performance
1 parent 64a7430 commit 5cd7a90

File tree

1 file changed

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

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
<td id="delete_button_container_<%- data.id %>" class="col-delete">
5959
<input type="hidden" class="delete-flag" name="option[delete][<%- data.id %>]" value="" />
6060
<?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?>
61-
<button title="<?php echo __('Delete') ?>" type="button"
61+
<button id="delete_button_<%- data.id %>" title="<?php echo __('Delete') ?>" type="button"
6262
class="action- scalable delete delete-option"
6363
>
6464
<span><?php echo __('Delete') ?></span>
@@ -100,7 +100,7 @@ require([
100100
if (isNewOption && !this.isReadOnly) {
101101
this.enableNewOptionDeleteButton(data.id);
102102
}
103-
this.bindRemoveButtons();
103+
this.bindRemoveButton(data.id);
104104
this.itemCount++;
105105
this.totalItems++;
106106
this.updateItemsCountField();
@@ -139,19 +139,11 @@ require([
139139
button.removeClassName('disabled');
140140
});
141141
},
142-
bindRemoveButtons: function() {
143-
var buttons = $$('.delete-option');
144-
for (var i = 0; i < buttons.length; i++) {
145-
if (!$(buttons[i]).binded) {
146-
$(buttons[i]).binded = true;
147-
Event.observe(buttons[i], 'click', this.remove.bind(this));
148-
}
149-
}
142+
bindRemoveButton: function(id) {
143+
$('delete_button_' + id).observe('click', this.remove.bind(this));
150144
}
151145
};
152146

153-
attributeOption.bindRemoveButtons();
154-
155147
if ($('add_new_option_button')) {
156148
Event.observe('add_new_option_button', 'click', attributeOption.add.bind(attributeOption));
157149
}

0 commit comments

Comments
 (0)