대시 보드 : 버튼 레이블을 변경하여 사용자 피드백 제공
-
10-07-2019 - |
문제
내가 원하는 것은 버튼 레이블을 통해 작동 상태에 대한 사용자 피드백을 제공하는 것입니다. 처음에는 버튼에 "저장"이 표시되면, 일단 클릭 한 후에는 레이블을 "저장"으로 변경하고 싶고 다른 함수를 입력하고 일단 함수가 반환되면 레이블을 "저장"으로 변경 한 다음 2 초를 일시 중지하고 레이블을 다시 초기로 설정합니다. " "값을 저장하십시오.
코드는 다음과 같습니다.
function myClickHandler(event)
{
document.getElementById("button").object.textElement.color = "saving...";
functionx ()
document.getElementById("button").object.textElement.color = "saved";
sleep (5000);
document.getElementById("button").object.textElement.color = "save";
}
문제는 어떤 이유로 든 마지막 document.getElementById("button").object.textElement.color = "save";
캔버스 나 버튼이 내가 나가면 렌더링되기 때문에 실제로 캔버스에서 볼 수 있습니다. myClickHandler
기능. 힌트가 있습니까?
미리 감사드립니다
해결책
이와 같은 것이 더 잘 작동 할 수 있습니다. Settimeout이 차단하지 않는다고 확신합니다.
function myClickHandler(event) {
updateLabel("saving...");
setTimeout("performFunctionX()", 250);
}
function performFunctionX() {
functionx;()
updateLabel("saved");
setTimeout("updateLabel('save')", 5000);
}
function updateLabel(labelText) {
document.getElementById("button").object.textElement.color = labelText;
}
제휴하지 않습니다 StackOverflow