How to link a button in one component to a div in anotherr component in reactjs app? - html

I am building a reactjs app which has a few components in it
(a navbar, a hero section,a form, and footer)
i want that when clicked on a button in navbar it scrolls down to form i.e another component,
I tried using react-router but it only renders that form and need it to scroll down to form keeping other components in place.
How can i achieve this?
basically this but in react

I think you may be able to achieve this by using vanilla Javascript like this:
<button
onclick="document.getElementById('idOfForm').scrollIntoView()">
</button>

Related

How to code a side-nav menu with nested accordion with Bootstrap?

I'm developing a website (Front-End: Bootstrap5, Back-End: PHP/MySQL).
I'm currently on the task of designing the Admin Interface.
So, I've retrieved an Admin Panel template from Bootstrap.
But I've tried to customize the side-nav menu with dropdown nested accordions when some of the dropdowns buttons opened all buttons at the same time.
I understand much of the code in the Admin Panel template.
But I just want the nested accordions to behave like a single-dropdown accordion when a button is cliked in the side-nav.
Thanks for the help

Can I close a bootstrap modal (v3) and link to a different site, without using JS?

I've created a modal (Bootstrap v3) on a site that doesn't allow for any Javascript, just HTML and CSS (Bootstrap v3). I'd like to have a button at the bottom that users can click to close the modal, that will also open up a new page. Currently the button can either only close the modal, or open a new page, not both.
Is there a way to do this in Bootstrap v3, without using JS?
I Agree

Is there a way to make HTML buttons act like radio buttons with React?

I have a group of <buttons> that I would like to act similarly to radio buttons. When a button is clicked, I need it to stay active, and when another button in that set is clicked, it needs to be made inactive and the new button needs to become active. I am using React.
I've tried different solutions and none have worked. Is there a way to do it with vanilla JS or React? Should I just use jQuery?
You can try some npm package that provides Radio Componenet to achieve this. You can search for packages and use the one you like. I am currently using Mantine which provides a lot of React components.
However, This is the one that I made. Take a look at it. Here is the link.
https://codesandbox.io/s/cold-water-ij5bfx?file=/src/App.js.

Which div to programmatically click to close bootstrap modal

I am writing tests for my Bootstrap 3.x webapp using Nightwatch. All is working fine, but I would like to add the "close modal by clicking somewhere next to it" in one of my tests. I don't seem to be able to identify the html element that's supposed to receive the click event however.
Can anyone help me with this?
Thanks!
The background is a div with class .modal-backdrop. According to the docs: "...generates a .modal-backdrop to provide a click area for dismissing shown modals when clicking outside the modal."

Bootstrap Modal only load div when clicked

Im using Bootstrap on a website where a page has a few modals.
Using Chrome Dev Tools i was testing the network usage and noticed that the images in the modal view are called/pre-loaded when the page loads - I guess that makes sense they are all in divs on a single page.
So my question is it possible to avoid that div from running only until the actual link to a particular modal is clicked?
Thanks.
Use $.get or $.load in the click event handler of the button to display the modal.
Note that the HTML data you load via this ajax technique must be in the right bootstrap modal template.
See this gist here