Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery ui sortable placeholder cannot change background colour

I can successfully change the border colour of the placeholder, but when I try change the background colour, nothing happens.

This jsfiddle code best explains it: http://jsfiddle.net/EUVrK/1/

like image 490
Kosta Kontos Avatar asked Jul 17 '12 13:07

Kosta Kontos


3 Answers

According to the jQuery UI Sortable Documentation you can provide a css class for the placeholder. You should be able to specify the background in this class.

Using the placeholder and the forcePlaceholderSize property, it works like a charm. I've updated the jsfiddle link

Hope that helps.

like image 137
p0wl Avatar answered Oct 05 '22 05:10

p0wl


I got some help from a friend on irc.freenode who suggested the following solution which does the trick.

ui.placeholder.css("visibility", "visible");
ui.placeholder.css("background-color", "red");

The background colour of the placeholder wasn't showing up because the actual element wasn't visible (I suppose it's set to hidden by default). So setting it to visible allows one to see the different background colour.

like image 24
Kosta Kontos Avatar answered Oct 05 '22 05:10

Kosta Kontos


CSS

.placeholderBackground{background-color:#FD6FB7;}

PARAMETER

$('.sortable').sortable({
axis: 'y', placeholder: 'placeholderBackground'
}).disableSelection();
like image 34
Vedat Taylan Avatar answered Oct 05 '22 05:10

Vedat Taylan