Wednesday, March 21, 2018

Re: Finding a decent ordering widget ...

Well, I stayed up and hacked around and found a short JQuery option in the right direction:

<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script>
  $
(function() {
    $
("#sortable").sortable({cancel: false});
    $
("#sortable").disableSelection();
 
});
</script>

<div id="sortable">
     
<div><button type="button">Item 1</button></div>
     
<div><button type="button">Item 2</button></div>
     
<div><button type="button">Item 3</button></div>
     
<div><button type="button">Item 4</button></div>
     
<div><button type="button">Item 5</button></div>
     
<div><button type="button">Item 6</button></div>
     
<div><button type="button">Item 7</button></div>
</div>

Demo here:  https://jsfiddle.net/pLu54k47/29/

But I do remain curious if there's a Django widget implementation for that kind of a list too. Or in fact any other elegant easily used form of such a sortable list. Don't hesitate to share your experience if you have any.

Also I'd like to tidy this sample up a bit if I can to produce a self contained widget with only the to Jquery library dependencies perhaps I guess. Part of me wonders if there isn't or shouldn't be, or if I should try and start, a Django widget library with Django Widgets like this for reuse. Just musing.

Regards,

Bernd.


On Wednesday, 21 March 2018 20:54:35 UTC+11, Bernd Wechner wrote:
Hmmm, my next problem.

I envisage a widget which is kind of like a HTML textarea, but basically each line would hold the name of a field say, and I'd like a user to be able to order the lines, not change the text. Basically click anbd drag lines up and down to reposition them.

I've poked around for HTML widgets for a bit now and find my main handicap is I'm not even sure how to describe this in terse search terms.

I know I've seen such widgets in practice - I didn't invent the idea ;-) - but have till now never needed one and suddenly I'm left wondering if there is one out there somewhere, and/or how I'd go about finding one. No real desire to try and build one with javascript right now, not least given I'm confident it exists already and I just don't know what it's called, how to describe it well or find it and well, DRY, I don't like spending my time recreating widgets that exist already. Not a priority.

Does anyone here have any experience? Places tom look, terms to use in searching for one?

Regards,

Bernd.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1b01ec47-3fb9-40b6-af2b-f40de93baf19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment