how to disable first item of a list from being sortable and drop target

I have a list of items and I want to make the first item in the list unsortable and unmovable. The first item in the list should always stay as the first item in the list. However, I can't seem to get it to work.here's my sorting code:

jQuery ->
  $('#lineup').sortable(
    axis: 'y'
    items: ".ui-state-enabled"
    cancel: ".ui-state-disabled"
    update: ->
      $.post($(this).data('update-url'), $(this).sortable('serialize'))
  );

and i'm using content_tag_for to load it up:

%ul.nav.nav-tabs.nav-stacked#lineup{"data-update-url" => sort_lineups_url}
  - @pieces.each_with_index do |piece, index|
    - if index == 0
      = content_tag_for(:li, piece, :class => 'ui-state-disabled') do
        = link_to "#{(index + 1).to_s + ' - ' + piece.name}", '#'
    - else
      = content_tag_for(:li, piece, :class => 'ui-state-enabled') do
        = link_to "#{(index + 1).to_s + ' - ' + piece.name}", '#'

what am i doing wrong? nothing i do seems to prevent the first item from being sorted and/or moved

Answers


Mmm, hard to say for certain. I've not used sortable/draggable combination before, moreover the UI documentation doesn't expressly address the sortable/draggable combination.

However, from what I have read in the documentation, something like this should work :

$(function() {
    $("#lineup li").disableSelection().addClass('ui-state-default').eq(0).addClass('ui-state-disabled');//alternatively, write classes as HTML attributes
    $("#lineup").sortable({
        items: "li:not(.ui-state-disabled)" //should disable draggable and sortable
    });
});

Need Your Help

scraping using beautiful soup

python python-2.7 web-scraping html-parsing beautifulsoup

I am scraping an article using BeautifulSoup. I want to scrape all of the p tags within the article body aside from a certain section. I was wondering if someone could give me a hint as to what I am

How to test winsock apps with bound connect AND listen sockets?

c++ binding winsock

I am trying to connect two of the same app with winsock, but the connecting side has to use ConnectEx() which requires a bound socket. So the problem is that when I try to loop back using ip 127.0....