Solved

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

Posted on 2014-01-13
3
271 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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)
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…

734 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