1

我使用 Golden Layout,所以我想更改特定堆栈组件的标题。例如,当我添加具有 2 个输入的 2 个堆栈并更改最后一个元素的标题时,不在特定堆栈中的所有元素的标题都会更改。

这是代码:

var addGroupement = function(title) {
var newItemStack = {
    id: 'stackId',
    type: 'stack',
    title: title,
    content:[{
        type: 'row',
        title: title,
        content:[{
            type: 'stack',
            componentName: 'template',
            componentState: { templateId: 'stackH' }
        }]
    }]          
};
$('#groupement').click(function(){
    var add = myLayout.root.contentItems[ 0 ].addChild( newItemStack );
    var stack = myLayout.root.getItemsById('stackId');
    console.log(stack);
    var input = $('<input type="text"/>');
    $('#test').append(input);
    input.on('change', function(event){
    for(i=0; i<stack.length ; i++){   
            stack[i].contentItems[0].setTitle(input.val());
        }
    })
});

};

结果:

在此处输入图像描述

请问你能帮帮我吗 !!

4

0 回答 0