简体   繁体   English

在数组中的工具提示中显示消息

[英]Display the messages in the tool-tip from an array

I am new to front-end and javascript. 我是前端和javascript的新手。 I am using react js . 我正在使用react js。 Here, I have a button which is like -> 在这里,我有一个类似->的按钮

<div className="fetchBtnDiv mx-auto" data-toggle="tooltip" data-placement="right"  title={this.generateToolTipMessage(this.state.hasAllFieldsFilld, this.state.hasAllHLowFieldsFilled, this.state.hasAllMidFieldsFilled)}>
                    <button className="btn btn-primary fetchBtnSize" disabled={(this.state.disableFetch || this.state.disableHighetch || this.state.disableMidFetch) || ( this.state.hasAllFieldsFilld ) || ( this.state.hasAllHLowFieldsFilled ) || ( this.state.hasAllMidFieldsFilled )}>Fetch Questions</button>
                </div>

Now, On tool tip I have to show user some messages , so I have written a function which is like , 现在,在工具提示上,我必须向用户显示一些消息,因此我编写了一个类似于的函数,

generateToolTipMessage(highData, lowData, mediumData) {
        let errorMessages = [];
        if(highData) {
            errorMessages.push("Please fill all the details in the High Level Criteria");
        } 
        if(lowData) {
            errorMessages.push("Please fill all the details in the Low Level Criteria");
        }
        if(mediumData) {
            errorMessages.push("Please fill all the details in the Medium Level Criteria");
        }
        return errorMessages;
    }

Now, It is like, There can be 3 messages at a time or 2 or may be 1 .so,Here Now I want to show user this messages. 现在,就像,一次可以有3条消息或2条消息,也可能是1条。所以,现在我想向用户显示此消息。

I am not getting a way to do this ? 我没有办法做到这一点? Can any one suggest me How I can do this ? 有人可以建议我该怎么做吗? Thanks.Any hint will be helpful. 谢谢。任何提示都会有所帮助。

state={
errors: '',
}

onMouseOverEventTriggered = () => {
       let errorMessages = [];
       if(highData) {
        errorMessages.push("Please fill all the details in the High Level Criteria");
       } 
          if(lowData) {
        errorMessages.push("Please fill all the details in the Low Level Criteria");
        }
        if(mediumData) {
        errorMessages.push("Please fill all the details in the Medium Level 
       Criteria");
    }
  this.setState({
  errors: errorMessages,
  })
}

Now the Html Part 现在,Html部分

 <div className="fetchBtnDiv mx-auto" data-toggle="tooltip" data-placement="right"  
   title={this.state.errors} onMouseOver={this.onMouseOverEventTriggered}>
                <button className="btn btn-primary fetchBtnSize" disabled= 
    {(this.state.disableFetch || this.state.disableHighetch || 
   this.state.disableMidFetch) 
    || ( this.state.hasAllFieldsFilld ) || ( this.state.hasAllHLowFieldsFilled ) || ( 
    this.state.hasAllMidFieldsFilled )}>Fetch Questions</button>
            </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM