Solved

Sortable (JQUI):  Don't allow items to be dragged above non sortable items.

Posted on 2014-01-13
3
267 Views
Last Modified: 2014-01-17
Ok before I write a bunch of code to catch and loop.  Any ideas on how to do this.

I have a UL that returns items.  They will always come back with "standard" items first then custom.

I have locked the standard ones down so they can't be moved/sorted in the list.  

The issue is:  I don't want any custom ones to be able to be dragged above the standard ones.  

Looks like this:
<ul id="jqWidSelected" class="jqSortableDash ui-sortable">
<li class="dBBBorBottom fixed dBBAlt" data-id="AE10BCF3-B2C0-474C-BA27-750426330529" style="height:70px;">
<li class="dBBBorBottom fixed" data-id="C30D2FAC-AE62-43D0-A833-73B5A67F2494" style="height:70px;">
<li class="dBBBorBottom dBBAlt" data-id="E0FE32F2-795E-4435-A117-EAFD28718FFD" style="height:70px;">
<li class="dBBBorBottom " data-id="8392F1B2-7115-4575-A230-611D55AC0140" style="height:70px;">
<li class="dBBBorBottom dBBAlt" data-id="066E3E2D-1182-4E39-B6BD-4BBE7659A2C3" style="height:70px;">
<li class="dBBBorBottom " data-id="2C0F5B37-824B-4D08-BFA0-1D2C0940F91F" style="height:70px;">
</ul>


NOTE:  fixed on LI determines locked or disabled

Open in new window


currently I sort with this:
    //  handle drag sort for dash order SORT
    $('.jqSortableDash').sortable({
        cancel: ".fixed",
        delay: 100,
        //connectWith: ".handleDrag",
        stop: function (event, ui) {
            p.HandleSortDash(ui, ui.item)
        },
        start: function (event, ui) { }
    }).disableSelection();

which calls this...basically just handles the order to the DB


//-------------------------    HANDLE SORT DASH   ------------------------------------------------------------ //
//
IPpage.prototype.HandleSortDash = function (ui, e) {
    var orderBy = '';

    $('#jqWidSelected li').each(function (i) {
        var n = $(this);
        n.find('.jqNum').html((i + 1));
        orderBy += '|' + n.attr('data-id');
    });
    //  update db
    this.HandleDBPreferenceCRUD(orderBy, 50);
    return;
}v

Open in new window


thanks in advance
0
Comment
Question by:skillilea
3 Comments
 
LVL 24

Expert Comment

by:lenamtl
ID: 39782279
Have you tried to use table instead of li,
there are great jQuery plugin for that kind of situation.

Footable
http://themergency.com/footable/

Datatable
http://datatables.net/
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39788610
Try changing
cancel: ".fixed",

Open in new window

to
items: ":not(.fixed)",

Open in new window

reference: http://jqueryui.com/sortable/#items

This seems to have the exact effect you want because the locked items are at the top to begin with (only tested in FireFox (but should not matter of course), on-line example here: http://schutt.nl/ee/Q_28336953/ ).
0
 

Author Closing Comment

by:skillilea
ID: 39788650
AWESOME!

Thanks tons!  Crazy simple.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Auto refresh part of an MVC5 View 7 63
Download a website to hdd 2 52
Add css and js to MVC Project not in project 9 27
is this a cms? 8 36
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now