Tom Gullen
Tom Gullen

Reputation: 61727

Jquery make newly inserted div draggable

I have the following snippet:

var Bar = $('#' + this.container.attr('ID') + 'b' + barID);
var Marker = $("<div class='marker m" + styleID + "'>" + label + "</div>");
Bar.parent().append(Marker);
Marker.draggable(
    {
        axis: "x",
        grid: [this.GridSize, this.GridSize]
    }
);

This doesn't make the marker draggable as I want it to, is there any way to make it draggable without assigning it an ID?

Upvotes: 1

Views: 71

Answers (1)

Jack Franklin
Jack Franklin

Reputation: 3765

You give the div assigned to Marker a class of marker mStyleId so couldn't you just select it using one of those?

$(".m"+styleId).draggable();

Upvotes: 3

Related Questions