Buka
Buka

Reputation: 1

jQuery's draggable plugin: Increase z-index on mousedown

I apply the draggable plugin to several elements and set the stack option to their class name. All I want is that when I mouse-down one of the elements its z-index value is increased so that it gets on the top. How would I achieve that? Currently it only works when I start dragging the element. I know how to write a function that would handle the issue but I would rather use the function that is already written in the draggable plugin. So, my question is how to trigger (onmousedown) the plugin's method that changes the z-index values?

Upvotes: 0

Views: 505

Answers (1)

As a solution you might write the following:

$('.those').mousedown(function (e) {
  var inst = $(this).data('draggable');
  inst._mouseStart(e);
  inst._trigger('start', e);
  inst._clear();
});

Check out jsfiddle!

Upvotes: 1

Related Questions