# Adding specific code to generic controllers

**URL:** <https://discuss.hotwired.dev/t/adding-specific-code-to-generic-controllers/2339>\
**Category:** General\
**Created:** [February 19, 2021, 1:32pm UTC](https://discuss.hotwired.dev/t/adding-specific-code-to-generic-controllers/2339 "2021-02-19T13:32:21Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![DannySantos](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/dannysantos/32/639_2.png) [@DannySantos](https://discuss.hotwired.dev/u/DannySantos)\
**Post date:** [February 25, 2021, 11:03am UTC](https://discuss.hotwired.dev/t/adding-specific-code-to-generic-controllers/2339/3 "2021-02-25T11:03:58Z")

</div>

Well the piece I’m currently working on is around allowing a user to specify the order in which something appears. So there is a `position` attribute on the model and collections are ordered by it.

So in this scenario the user is dragging collection items into their specified order. Once they release the draggable element, I want to iterate over the hidden `position` fields that each of them has and set them to 1, 2, 3, 4 etc. The code is something like:

```
$(".sortable-list-item").each(function(i, listItem) {
  $(listItem).find(".signatory-fields-position").val(i + 1);
});

```

But of course this is just one example of what I might want to use drag and drop for.

---

_[View the full topic](https://discuss.hotwired.dev/t/adding-specific-code-to-generic-controllers/2339)._
