在Azle中克隆布局后更改多个按钮标题

时间:2018-05-31 20:55:07

标签: azle

我有一个布局,其中包含以下按钮:

enter image description here

...然后我克隆制作另一个按钮布局,而不必重新创建所有元素:

clone_layout("my_sections", 2, {
        "copy_class" : "data_gather_options",
        "copy_instance" : 1,
        "this_class" : "data_prep_options",
        "row_class" : "data_prep_options_row",
        "cell_class" : "data_prep_options_cells"
    })

enter image description here

由于这个新克隆是一个精确的副本,我如何替换按钮标题?

1 个答案:

答案 0 :(得分:0)

您可以使用一系列新按钮标题组合Azle的 call_multiple replace_property 功能:

新按钮标题

new_titles = ['TITLE 1','TITLE 2','TITLE 3','TITLE 4']

在所有克隆按钮中添加新标题

call_multiple({
    "iterations" : 4,
    "function" : `
        replace_property('original_buttons', 5 + index, {
            "text" : hold_prep_butt_titles[index]
        })
       `
})

enter image description here

请注意我们访问replace_property函数中的call_multiple索引,以确保我们定位正确的按钮。您还可以将事件添加到新按钮而不必担心旧事件,因为Azle克隆不会克隆事件绑定。

我们可以在单引号之间添加任意数量的功能,在call_multiple' s" function"选项。例如,我们可能也希望在此处添加所有事件:

new_events = ["alert('first')", "alert('second')", "alert('third')", "alert('fourth')"] 

call_multiple({
        "iterations" : 4,
        "function" : `
            replace_property('original_buttons', 5 + index, {
                "text" : hold_prep_butt_titles[index]
            })
            add_event('original_buttons', 5 + index, {
                "type" : "click",
                "function" : new_events[index]
            })
           `
    })

enter image description here

相关问题