[英]javascript button onClick do not wait for function return true and opens the link
[英]javascript wait return function into onclick
我們有以下代碼(使用DHTMLX和DHTMLXMESSAGE):
myCheckBox.attachEvent('onEditCell', function(stage,rId,cInd,nValue,oValue){
dhtmlx.confirm({
type:"confirm",
text: "Are you sure?",
callback: function(result){
if(result) {
return true;
}
return false;
}
});
});
OnEditCell事件應返回“ true”或“ false”以驗證操作。
現在,我的代碼始終選中我的復選框,然后顯示確認彈出窗口。
您不能在異步函數上使JavaScript阻塞。
讓事件處理程序始終返回false。
然后在回調中觸發其功能,而不是嘗試返回true。
您無法將任何內容返回給attachEvent回調。 根據您的確認復選框的結果,執行相關代碼
> callback: function(result){
> if(result) {
> //don't returnfrom here
// execute your code here only.
> }
>
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.