0
当前我正在创建一个拖放应用程序并使用jQuery-ui。jQuery拖放动态高度
我的问题是当我在我的区域添加容器元素,并在容器内添加RadioButtonElement。所以当我在我的容器只有1或2个无线电元素时,容器高度默认为300px,但是当我在容器内添加3个或更多RadioButtonElement时,容器高度仍然是300px而不是动态的,它不会改变高度容器。
请看附件。
这里是的jsfiddle:https://jsfiddle.net/2sob2ctf/3/
谢谢 乌斯曼
我的代码:
var origin = 'sortable';
/*
Schrittbox
*/
$(".builder .headbox").draggable({
appendTo:".buildplace",
connectToSortable:".buildplace",
helper: "clone",
revert: "invalid",
start: function() {
origin = 'draggable';
},
stop: function (e, t) {
bindDraggable(".headbox .content", ".radioContainer");
}
});
$(".buildplace").droppable({
accept: ".headbox",
greedy: true,
drop: function (event, ui) {
console.log("schrittbox")
if (origin === 'draggable') {
ui.draggable.html($(".view",ui.draggable).html());
ui.draggable.addClass("dropped");
origin = 'sortable';
}
}
}).sortable();
/* ende
/*
radioContainer
*/
$(".builder .radioContainer").draggable({
connectToSortable:".headbox >.content",
helper: "clone",
start: function() {
origin = 'draggable';
},
stop: function (e, t) {
bindDraggable(".radioContainer .content", ".radioButton");
}
});
/*
radioButton
*/
$(".builder .radioButton").draggable({
connectToSortable:".radioContainer .content",
helper: "clone",
start: function() {
origin = 'draggable';
},
});
function bindDraggable(selector, accept){
$(selector).droppable({
accept: accept,
greedy: true,
drop: function (event, ui) {
console.log("radiocontainer")
if (origin === 'draggable') {
ui.draggable.html($(".view",ui.draggable).html());
origin = 'sortable';
}
}
}).sortable({
revert: true
});
}
部分是,你用'的容器和孩子都content'类。我会建议你调整'height:300px;'到'min-height:300px;'以允许框增长并且不被锁定。由于这将适用于这两个元素,它会导致问题。 – Twisty