1

How can I change CSS property once sorted. Something likes this:

    $( "#sort" ).sortable({

        $(#div1).css("background-color","yellow");
    }); 

Thanks alot

1
  • Can you be more specific? Are you trying to style them to show which one was sorted? Commented Aug 5, 2011 at 14:55

3 Answers 3

6

When you call initiate the plugin, make sure you pass a handler for the stop event:

$('#sort').sortable({
    stop: function(){
        $('#div1').css('background-color','yellow');
    }
});
Sign up to request clarification or add additional context in comments.

3 Comments

This event is triggered during sorting.
@Jacek_FH - True. Changed to stop(). Was going to suggest update() but it specifically says that it is fired "When the user stops sorting and the DOM positions have changed" which means if the user lets the sort finish on its own or the data is already sorted, nothing will happen.
I didn't use that because I fill that update is triggered after stop and after following DOM update. Thing to test anyways.
2

http://docs.jquery.com/UI/Sortable#events

$( ".selector" ).sortable({
    update: function(event, ui) { ... }
});

Comments

2

Look at the events for sortable on the jQuery UI website: http://jqueryui.com/demos/sortable/#events

Depending on the event you want, you can use:

$( "#sort" ).sortable({
    change: function(){
        $("#div1").css("background-color","yellow");
    }
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.