Skip to content

Add custom label for buttons #14

@paologf

Description

@paologf

Hello,

is it possible add into the options parameter of confirm function a dictionary with a custom label for each button?
Maybe something like {"cancel":"Cancel Button Label","close":"Cancel Button Label","ok":"Ok Button Label"} , pass into the getTemplate function this labels dictionary and use call labels[name] || name.

   function getTemplate(title, msg, value, buttons, labels) {
    const encodedMsg = msg.replace(/\n/g, '<br>');
    
    return `<div class="page">
        <div data-name="js-close" class="close-button"></div>
        <header>${ title }</header>
        <div class="content-area">${ encodedMsg }${ value }</div>
        <div class="action-area">
            <div class="button-strip"> ${
                buttons.map((name, i) =>
                    `<button tabindex=${ i } data-name="js-${ name.toLowerCase() }">${ labels[name] || name }</button>`
                ).join('')
            }
            </div>
        </div>
    </div>`; 
}

Thanks

Paolo

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions