Отключение кнопки после однократного нажатия

Просто хотелось указать, что встроенная функция sink имеет хорошие примеры различных способов установки аргументов в функции:

> sink
function (file = NULL, append = FALSE, type = c("output", "message"),
    split = FALSE)
{
    type <- match.arg(type)
    if (type == "message") {
        if (is.null(file))
            file <- stderr()
        else if (!inherits(file, "connection") || !isOpen(file))
            stop("'file' must be NULL or an already open connection")
        if (split)
            stop("cannot split the message connection")
        .Internal(sink(file, FALSE, TRUE, FALSE))
    }
    else {
        closeOnExit <- FALSE
        if (is.null(file))
            file <- -1L
        else if (is.character(file)) {
            file <- file(file, ifelse(append, "a", "w"))
            closeOnExit <- TRUE
        }
        else if (!inherits(file, "connection"))
            stop("'file' must be NULL, a connection or a character string")
        .Internal(sink(file, closeOnExit, FALSE, split))
    }
}
41
задан Preston Badeer 3 January 2013 в 20:51
поделиться

1 ответ

Если при установке disabled = "disabled" сразу после того, как пользователь нажимает кнопку, и форма не отправляется из-за этого, вы можете попробовать два things:

//First choice [given myForm = your form]:
myInputButton.disabled = "disabled";
myForm.submit()

//Second choice:
setTimeout(disableFunction, 1);  
//so the form will submit and then almost instantly, the button will be disabled  

Хотя, честно говоря, будет лучший способ сделать это, чем тот.

11
ответ дан 27 November 2019 в 00:32
поделиться
Другие вопросы по тегам:

Похожие вопросы: