reagent-project/reagent-cookbook

Sortable

Closed this issue · 6 comments

The problem with the sortable example(s) is it doesn't explain how to get the sorting data out of it...

I'd like to feed the positional data back into my reagent app so I can send it to a backend API, for example.

Are you referring to the DataTables recipe? If so, I would check out this page on server-side processing.

Oh sorry, no I was referring to sortable-portlets (https://github.com/reagent-project/reagent-cookbook/tree/master/recipes/sortable-portlets) which is very similar to just plain jquery sortable.

Oh no problem, that was my mistake. :)

Do either of these work for you?

http://www.codeproject.com/Tips/283694/Persist-JQueryUI-Sortable-position
http://www.petefreitag.com/item/736.cfm

Looks like they leverage the update event with an ajax call.

Oh I know how to do it in jquery. I was just commenting that it isn't in your example, which kind of defies the point of having drag 'n drop a little bit, but maybe I'm just being obtuse.

I'm actually implementing it using google closure's goog.fx.DragListGroup class. I'll have to work out how to cancel the drag on drop, tho, (and use the data backing of my Reagent atoms/cursors to re-render the position of the elements), because it's data-driven.

Thanks for making all these examples!

Oh you aren't being obtuse at all, I really appreciate your input! I like the idea of keeping the sortable recipe as is (without any backend communication), for simplicity's sake. But I would like a 'level 2' recipe to help alleviate some of the concerns that you are posing here.

Would you be willing to make a recipe that shows how to do something like this? It can be with goog.fx.DragListGroup class or whatever you prefer!

TLDR; I'll give it a crack sometime.

More involved answer is:

Oh cool :) Well I don't like to promise anything because my current razor sharp focus is finishing off the clojure version of our content management system at www.getcontented.com.au but I wouldn't mind trying my hand at it.

Irrespective of whether there's a backend, being able to "get at" the position data makes a lot of sense for any use case of "sortable" or drag 'n drop... (for example, the moment after one has implemented toy drag 'n drop sorting, one then immediately wants to implement something similar to "mapped drap 'n drop sorting" - where dragging within ONE list actually has impact on another list. (And a whole range of other instances simiar to this, but based around the idea of knowing the sorted order in some capacity).

My problem with starting down some tutorial endeavour is that it's not incredibly efficient in terms of impact. You write one tutorial for jquery, you write another for google closure, you write a third for backbone, and so on... if I want to learn to cook, then recipes aren't the best way to do that. They provide a way to cook ONE thing.

That discussion is probably way beyond the scope of this document. :)