Solved

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

Posted on 2014-01-13
3
272 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 25

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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
Suggested Courses

617 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