Если бы мне нужно было использовать бутстраповский аккордеон в динамике например при посадке на вордпресс и я не знаю сколько будет ячеек как по вашему я это буду делать?
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">
<select id='my-id'></select>
</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">
<select id='my-id'></select>
</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">
<select id='my-id'></select>
</div>
</div>
$('#my-id').select2();
$('select', '<tab-id>').select2();
<div class="accordion" id="accordionExample">
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<div id="collapseOne" class="accordion-collapse collapse show" aria-labelledby="headingOne" data-bs-parent="#accordionExample">
$( '<element>', '#home' )
$( '<element>', '#profile' )
$( '<element>', '#contact' )
На странице не может быть одинаковых id
id | name |
---|---|
1 | col1 |
2 | col2 |
id | name | params |
---|---|---|
1 | user1 | [{"col_id": 1, "place": 2}, {"col_id": 2, "place": 1}] |
2 | user2 | [{"col_id": 1, "place": 1}, {"col_id": 2, "place": 2}] |
class Something < ActiveRecrd::Base
scope :for_ids_with_order, ->(ids) {
order = sanitize_sql_array(
["position(id::text in ?)", ids.join(',')]
)
where(:id => ids).order(order)
}
end
# usage:
Something.for_ids_with_order([1, 3, 2])
DEPRECATION WARNING: Dangerous query method (method whose arguments are used as raw SQL) called with non-attribute argument(s)
Non-attribute arguments will be disallowed in Rails 6.0. This method should not be called with user-provided values, such as request parameters or model attributes