Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add text to placeholder in a jQuery Sortable

I'm trying to add text to the placeholder box that shows while dragging the sortable item. is there a function in jQuery's UI that I'm missing? Right now I'm trying to .append() the info, but it's not working.

Here's the jQuery function:

//Sortable Function - Edit Wizard
$(function () {

    //add text to placeholder box
    if ($('.ui-state-highlight').is(':visible')) {
        $('.ui-state-highlight').append('<span>MOVE HERE</span>');
    };


    $(".sortable").sortable({
        placeholder: "ui-state-highlight",
        //revert: true,
        grid: [20, 20],
        handle: '.editMove',
        opacity: 0.6,
        scroll: true,
        scrollSensitivity: 80,
        zIndex: 10
    });
    $(".sortable").disableSelection();
});

Edit

I guess there needs to be some .live() change function for the .append()?

like image 942
Mike Barwick Avatar asked Jan 16 '23 18:01

Mike Barwick


1 Answers

You can modify the placeholder from the start callback, like this:

$('#my-sortable').sortable({
    start: function(event, ui) {
        ui.placeholder.html('Placeholder Content!');
    }
});
like image 92
Synexis Avatar answered Jan 23 '23 04:01

Synexis