Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions drag_and_drop_v2/public/js/drag_and_drop_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function DragAndDropEditBlock(runtime, element) {
name = 'zone-',
$elements = _fn.build.$el,
num,
obj;
zoneObj;

if (!oldZone) oldZone = {};

Expand All @@ -168,7 +168,9 @@ function DragAndDropEditBlock(runtime, element) {
_fn.build.form.zone.obj.push(zoneObj);

// Add fields to zone position form
$elements.zones.form.append(inputTemplate(zoneObj));
$zoneNode = $(inputTemplate(zoneObj));
$zoneNode.data('index', num);
$elements.zones.form.append($zoneNode);
_fn.build.form.zone.enableDelete();

// Add zone div to target
Expand All @@ -183,12 +185,21 @@ function DragAndDropEditBlock(runtime, element) {
remove: function(e) {
var $el = $(e.currentTarget).closest('.zone-row'),
classes = $el.attr('class'),
id = classes.slice(classes.indexOf('zone-row') + 9);
id = classes.slice(classes.indexOf('zone-row') + 9),
index = $el.data('index'),
array_index;

e.preventDefault();
$el.detach();
$('#' + id, element).detach();

// Find the index of the zone in the array and remove it.
for (array_index = 0; array_index < _fn.build.form.zone.obj.length;
array_index++) {
if (_fn.build.form.zone.obj[array_index].index == index) break;
}
_fn.build.form.zone.obj.splice(array_index, 1);

_fn.build.form.zone.formCount--;
_fn.build.form.zone.disableDelete();

Expand Down