How To Make Popup Modal Appear When Clicking a Link?

I am trying to create a Login Modal Form for an application. However, I want the popup to appear when I click a link versus a button. In other words, when I click the login link in my navbar, I don’t want to be redirected to another page entirely. I just want the modal to pop up.

I’m very new to ReactJS, so I’m not sure how to go about this. Could somebody please help me understand how to get this function to work? I’d really appreciate it.

Additionally, if anyone knows of some great resources on how to implement a proper login form, I would also greatly appreciate that. I found a few on CodePen, but none of them really show a clear and approachable way on how to build this component. At least, for a beginner like me.

Located below is my code. Also, if it helps, I provided the link to the site I am currently using as a reference to build this code.



import React from 'react'; import {BrowserRouter, Route, Switch} from 'react-router-dom' import Navbar from './components/Navbar/navbar.js'; import Footer from './components/Footer/footer.js'; import Home from './pages/Home/home.js'; import Login from './pages/Login/login.js'; import Languages from './pages/Languages/languages.js';  function App() {   return (     <div className="App">       <BrowserRouter>         <Navbar/>           <Switch>             <Route exact path="/" component={Home}/>             <Route path="/login" component={Login}/>             <Route path="/languages" component={Languages}/>           </Switch>       </BrowserRouter>       <Footer />     </div>   ); }  export default App; 


import React, { Component } from 'react'; // import { connect } from 'react-redux'; import Modal from 'react-bootstrap/Modal'; import Button from 'react-bootstrap/Button'; import './login.css';  class Login extends Component {     constructor(props, context) {         super(props, context);          this.handleShow = this.handleShow.bind(this);         this.handleClose = this.handleClose.bind(this);          this.state = {           show: false,         };       }        handleClose() {         this.setState({ show: false });       }        handleShow() {         this.setState({ show: true });     }      render() {         return (             <>                 <Button variant="primary" onClick={this.handleShow}>                   Launch demo modal                 </Button>                  <Modal show={} onHide={this.handleClose}>                   <Modal.Header closeButton>                     <Modal.Title>Login</Modal.Title>                   </Modal.Header>                   <Modal.Body>...</Modal.Body>                   <Modal.Footer>                     <Button variant="danger" onClick={this.handleClose}>                       Cancel                     </Button>                   </Modal.Footer>                 </Modal>             </>         );     } }  export default Login; 

Wait for an element to exist in DOM before clicking it

Here is the problem: some script is injecting some HTML5 elements (actually a button with the #thebutton ID) to the current DOM.

But this is a third party script and I have no control of when this will be injected to the page. I need to click automatically on this button when the button is injected to the DOM. Here is my solution so far.

It’s actually working but I’m not sure on how fine this code is. My first guess is that I may use the clearTimeout() method. Is there anything else I must do?

<script type="text/javascript">     function waitForElementToDisplay(selector, time) {         if (document.querySelector(selector) !== null) {             document.getElementById("thebutton").click();             return;         } else {             setTimeout(function () {                 waitForElementToDisplay(selector, time);             }, time);         }     }     // onload     (function () {         waitForElementToDisplay("#thebutton", 500);     })(); </script> 

Here is a simulated jsFiddle of the whole process:

How to remove a dynamically created list item that has a specific class when clicking on a button?

A user adds list items dynamically and clicks them to mark them as complete once selected as complete a user should then be able to click the button and remove them from the page. I am unsure as to why the remove functionality does not work any help appreciated!

const addText = function () { $  addBtn.on("click", function () {     addLI(); }); };  const addLI = function () { if($  inputBox.val()!=="") {     $  newItemList.append("<li>" +"<p onclick = 'markComplete(this)'>"+  $  inputBox.val() +"</p>" + "</li>"); } $  removeBtn.on('click', function() {     if($  ('li').hasClass('finishedItem'))     {         $  ('li').remove();     } }); }; function markComplete(p){ $  (p).toggleClass("finishedItem") } 

How could I have the Time automatically entered in a cell by clicking a button or double clicking a cell

The goal is to have a blue collar worker double click on a cell (or a button) in a certain range and have the time entered. The time is often put into the cell incorrectly.

The goal is to have it in military time.

I do know about the the “ctrl – shift :” command and I think i could find a better solution.

activate the select by clicking on the block

How to activate select if i click on block? I found several options on the Internet, but none of them works.Where is the mistake?


<li name='click' class="nav-link" id="demoShowSelected">                                     <img class=" ukr"  src="{{ URL::asset('images/ukraine.svg')}}">                                     <img class=" eng" src="{{ URL::asset('images/united-kingdom.svg')}}">                                     <img class=" rus" src="{{ URL::asset('images/russia.svg')}}">                                     <select  name="select" id="selectLaung">                                         <option value="ukr">Українська</option>                                         <option value="rus">Русский</option>                                         <option value="eng">English</option>                                     </select>                                 </li> 


$  (document).on("click", "[name='click']", function () {      var myEvent = document.createEvent("MouseEvents");     myEvent.initMouseEvent("mousedown");     $  ("[name='select']")[0].dispatchEvent(myEvent);  }); 

Clicking on product (Edit option) from ADMIN is throwing a —–“Fatal error: Uncaught TypeError argumentsResolver(‘created_by)'”

The problem is the same as here,[Magento migration product error: UiComponentFactory->argumentsResolver('created_by', NULL)

but it has not solved my problem. everyone have any other solutions?

Fatal error: Uncaught TypeError: Argument 2 passed to  Magento\Framework\View\Element\UiComponentFactory::argumentsResolver() must be of the type array, null given, called in  /vendor/magento/framework/View/Element/UiComponentFactory.php on line 222 and defined in  /vendor/magento/framework/View/Element/UiComponentFactory.php:174 Stack trace: #0  /vendor/magento/framework/View/Element/UiComponentFactory.php(222):  Magento\Framework\View\Element\UiComponentFactory->argumentsResolver('created_by', NULL)  #1 /vendor/magento/module-ui/Component/Form/Field.php(85):  Magento\Framework\View\Element\UiComponentFactory->create('created_by', '', Array)  #2 /vendor/magento/framework/View/Layout/Generator/UiComponent.php(164):  Magento\Ui\Component\Form\Field->prepare()  #3 /vendor/magento/framework/View/Layout/Generator/UiComponent.php(161):  Magent in /vendor/magento/framework/View/Element/UiComponentFactory.php on line 174