У меня есть элемент, который можно перетаскивать. И я условно уничтожаю ui-draggable от элемента. Если флажок установлен, то примените ui-draggable, а если нет, то уничтожьте его. Теперь я хочу проверить, уничтожен ли ui-draggable. Я хочу вернуть true, если это так, а если нет, то false.
JQuery
$("#movable").click(function () {
if ($("#movable").is(':checked')) {
$("#cont > #text").draggable({
scroll: true,
containment: '#cont'
});
}
else {
$("#cont > #text").draggable("destroy");
}
});
$("#text").click(function () {
//Here i want to check is draggable destroyed from the element or not.
});
Отметить
<input type="checkbox" id="movable" style="margin-top:10px;" />
<div id="cont">
<div id="text">Hello World</div>
<div>
Любая помощь будет оценена. Спасибо.
Вот один из способов сделать это:
$("#movable").click(function () {
if ($("#movable").is(':checked')) {
$("#cont > #text").data('destroyed', false).draggable({
scroll: true,
containment: '#cont'
});
}
else {
$("#cont > #text").data('destroyed', true).draggable("destroy");
}
});
$("#text").click(function () {
var isDestroyed = $("#cont > #text").data('destroyed');
});