Simplify JavaScript to toggle investment selection

We don't need to replace the whole row, since the changes only affect
the button. Therefore, we don't need to depend on an `inserted` event to
decide which columns to render in that row.
This commit is contained in:
Javi Martín
2024-10-06 14:22:18 +02:00
parent 9e5566cee4
commit f72daff71f
2 changed files with 3 additions and 6 deletions

View File

@@ -80,9 +80,6 @@
App.ColumnsSelector.toggleColumn(event);
}
});
$(".column-selectable").on("inserted", function() {
App.ColumnsSelector.initColumns();
});
},
destroy: function() {
$("#js-columns-selector-wrapper").children(":not(#column_selector_item_template)").remove();

View File

@@ -1,3 +1,3 @@
$("#<%= dom_id(@investment) %>").replaceWith(
"<%= j render Admin::BudgetInvestments::RowComponent.new(@investment) %>"
).trigger("inserted");
$("#<%= dom_id(@investment) %> [data-field='selected']").html(
"<%= j render(Admin::BudgetInvestments::ToggleSelectionComponent.new(@investment)) %>"
);