在另一个按钮时钟之后禁用按钮,启用按钮

时间:2019-10-22 07:48:41

标签: javascript reactjs ecmascript-6

我希望在单击Copy List To Below之前禁用Save按钮。

当前这是Copy List To Below按钮

<button type="button" className={classes["copy-btn"] + " btn-cancel mt-3"} onClick={(event) => this.copyData(event)}>Copy List To Below {_.size(this.state.protestList) > 1 ? _.size(this.state.protestList) + " Groups" : 'Group'} </button>

这是我的Save按钮

     <button type="submit" className={classes["save-btn"] + " btn-save"} onClick={(event) => this.saveData(event)}>Save</button>

下面是受人尊敬的功能

    saveDate = (event, data) => {
        if(event) {
            //Do something
        }
        else {
            //Return Error
        }
    }

    copyData = (event, data) => {
            if(event) {
                //Do something
            }
            else {
                //Return Error
            }
        }

正如我所说,只有完成复制后,才能点击“保存”按钮

2 个答案:

答案 0 :(得分:1)

给出两个ID并添加click事件和切换按钮disable属性,如下所示。简单点。您的按钮具有不必要的属性,请删除这些属性。

CORE JAVASCRIPT

python manage.py shell --settings=settings.my_override

REACT JS

<button type="button" id="coptBtn" class ="btn-cancel mt-3" >Copy List To Below</button>
<button id="saveBtn" type="submit" class="" >Save</button>

var coptBtn  = document.getElementById('coptBtn');
var saveBtn  = document.getElementById('saveBtn');
saveBtn.disabled = true;
coptBtn.addEventListener('click', (evt) => {
    saveBtn.disabled = false;
 });

答案 1 :(得分:0)

尝试此代码。

browser.debug()