How to save values from Sortable Unordered List?

31 views
Skip to first unread message

Fai Wong

unread,
Jul 15, 2013, 2:37:05 PM7/15/13
to rubyonra...@googlegroups.com
I've a sortable unordered list as follows. How do I use controller to detect this element and get the contents to save each LI item into a row in the database?

<ul id="show-items" class="ui-sortable">
<li id="todo-163"><span class="editable">1. Good</span> <a href="#" style="display: none;">X</a></li>
<li id="todo-190"><span class="editable">2. Better</span> <a href="#" style="display: none;">X</a></li>
<li id="todo-189"><span class="editable">3. Best</span> <a href="#" style="display: none;">X</a></li>
</ul>

Tamara Temple

unread,
Jul 15, 2013, 7:15:55 PM7/15/13
to rubyonra...@googlegroups.com
There is just so much here you've left us to guess at.

Even the question "how do I use a controller to detect this" is rather odd. Controllers do not detect things in a web page, they respond to HTTP requests.

Where did this list come from? How was it initially generated? Seeing it's apparently some kind of to-do list, is it something that is based upon a javascript library or framework such as backbone, ember, angular, etc? If the latter, those all have really great methods for interacting with a server controller, but not from a presentation view such as this.

Indeed, going from an unordered list such as this, you must create a javascript capability that can strip the content of that list, package things up in JSON, and make a call from javascript to the server controller, things which the above frameworks do for you already.


Reply all
Reply to author
Forward
0 new messages