Reece Jones
Joined
440 Experience
4 Lessons Completed
0 Questions Solved
Activity
Would love a tutorial from Chris if this is possible for Rails :D
that will display the items in reverse, sure. But it is not quite what I'm meaning.
Let's say I drag and drop the first div to the second div. The event will still contain the following:
newIndex: 1
oldIndex: 0
what I want it to be:
newIndex: 2
oldIndex: 3
Is there anyway to reverse the index and position order? For example:
<div>First div</div> <%# index: 3, position: 3 %>
<div>Second div</div> <%# index: 2, position: 2 %>
<div>Third div</div> <%# index: 1, position: 1 %>
<div>Fourth</div> <%# index: 0, position: 0 %>
This way it appears and is applied in descending order instead of ascending
Say I wanted to add multiple separate search scopes instead of just one. For example
@employees = @employees.search(params[:query]) if params[:query].present?
@employees = @employees.start_date(params[:start_date]) if params[:start_date].present?
@employees = @employees.created_at(params[:created_at]) if params[:created_at].present?
...
How could I simplify and clean up this logic? Is there a way to iterate through these?