Fix level2 menu cannot delete bug.

This commit is contained in:
BoHung Chiu 2022-03-15 13:08:03 +08:00
parent 2a4270d1a7
commit 626236014f
1 changed files with 5 additions and 5 deletions

View File

@ -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));