@@ -445,12 +445,16 @@ function buildTiles(list) {
445445 this.initialPosition = {};
446446 this.changingItemId = 0;
447447 this.questionsColumns = <?php echo PluginFormcreatorSection::COLUMNS ; ?> ;
448+ this.dirty = false;
448449
449450 this.setupGridStack = function (group) {
451+ var that = this;
450452 group
451453 .on('resizestart', this.startChangeItem)
452454 .on('dragstart', this.startChangeItem)
453- .on('change', this.changeItems)
455+ .on('change', function(event, item) {
456+ that.changeItems(event, item)
457+ })
454458 .on('dragstop', function(event, item) {
455459 setTimeout(function() {
456460 item.helper.find('a').off('click.prevent');
@@ -462,6 +466,7 @@ function buildTiles(list) {
462466 };
463467
464468 this.initGridStack = function (sectionId) {
469+ var that = this;
465470 var group = $('#plugin_formcreator_form.plugin_formcreator_form_design [data-itemtype="PluginFormcreatorSection"][data-id="' + sectionId + '"] .grid-stack');
466471 group.gridstack({
467472 width: this.questionsColumns,
@@ -482,6 +487,7 @@ function buildTiles(list) {
482487 }
483488 }).success(function(data, httpCode) {
484489 var grid = group.data('gridstack');
490+ that.dirty = true;
485491 $.each(data, function(index, question) {
486492 grid.addWidget(
487493 question.html,
@@ -496,6 +502,7 @@ function buildTiles(list) {
496502 1
497503 );
498504 });
505+ that.dirty = false;
499506 }).complete(this.setupGridStack(group));
500507 };
501508
@@ -519,17 +526,15 @@ function buildTiles(list) {
519526 }
520527 });
521528 this.changingItemId = Number($(event.target).attr('data-id'));
522- this.dirty = false;
523529 };
524530
525531 /**
526532 * Event handler : change an item (resize or move)
527533 */
528534 this.changeItems = function (event, items) {
529535 if (this.dirty === true) {
530- // return;
536+ return;
531537 }
532- this.dirty = true;
533538 var that = this;
534539 var changes = {};
535540 $.each(items, function(index, item) {
0 commit comments