From 626236014f34a477053e5dfef43912f186aa1d02 Mon Sep 17 00:00:00 2001 From: Bohung Date: Tue, 15 Mar 2022 13:08:03 +0800 Subject: [PATCH] Fix level2 menu cannot delete bug. --- app/assets/javascripts/survey.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/survey.js b/app/assets/javascripts/survey.js index 9691e5a..3458ba1 100644 --- a/app/assets/javascripts/survey.js +++ b/app/assets/javascripts/survey.js @@ -189,11 +189,11 @@ function parse_2_level_options( l, x, data ){ var level2_controls = level2.find('.controls .add-target') if (data.level2){ $.each(data.level2.reverse(),function ( level2_x, level2_data ){ - var level2_child = $('#template-survery-option').tmpl(setEditQuestionAttributes( l, "", level2_data, x+"][level2]["+level2_x, "options" )) + var level2_child = $('#template-survery-option').tmpl(setEditQuestionAttributes( l, "", level2_data, x+"][level2_attributes]["+level2_x, "options" )) level2_controls.prepend(level2_child) }) }else{ - var level2_child = $('#template-survery-option').tmpl(setData(l, "", x+"][level2]["+level2_x, "options" )) + var level2_child = $('#template-survery-option').tmpl(setData(l, "", x+"][level2_attributes]["+level2_x, "options" )) level2_controls.prepend(level2_child); } wrapper.find('.level1_wrapper').prepend(level1) @@ -203,7 +203,7 @@ function parse_2_level_options( l, x, data ){ function add_2_level_options(_index, _i, _className){ var level1 = $('#template-survery-option').tmpl(setData(_index, "", _i, _className)); var level2 = $('#template-survery-option-level2-wrapper').tmpl() - var level2_child = $('#template-survery-option').tmpl(setData(_index, "", _i+"][level2][0", _className)) + var level2_child = $('#template-survery-option').tmpl(setData(_index, "", _i+"][level2_attributes][0", _className)) level2.find('.controls .add-target').prepend(level2_child); var wrapper = $('#template-survery-option-leve11-wrapper').tmpl(setData(_index, "", _i, _className)); wrapper.attr('data-index',_i) @@ -235,7 +235,7 @@ function onQuestionTypeChanged ( $fieldType, _val ){ wrapper.find('.level1_wrapper').prepend($(this).clone()) wrapper.attr('data-index',_i) var level2 = $('#template-survery-option-level2-wrapper').tmpl() - var level2_child = $('#template-survery-option').tmpl(setData(_index, "", _i+"][level2][0", 'options')) + var level2_child = $('#template-survery-option').tmpl(setData(_index, "", _i+"][level2_attributes][0", 'options')) level2.find('.controls .add-target').prepend(level2_child) wrapper.append(level2) $(this).replaceWith(wrapper) @@ -375,7 +375,7 @@ $(function() { }else{ _i = $(this).parents('.level1').data('index') var level2_index = $add_btn.parents('.add-target').eq(0).children('.input-append').length - option_html = $('#template-survery-option').tmpl(setData(_index, "", _i+"][level2]["+level2_index, _className)); + option_html = $('#template-survery-option').tmpl(setData(_index, "", _i+"][level2_attributes]["+level2_index, _className)); } }else{ option_html = $('#template-survery-option').tmpl(setData(_index, "", _i, _className));