Ranny
Ranny

Reputation: 136

How to let a function force bootstrap modal to popup?

Hello there : actually i am trying to do some JQUERY things in React and it is look to me like a magic, i read a lot and search for a way to run the Bootstrap, Modal with an external function .

This is my online code : https://codesandbox.io/s/rwnloz44kq

you will see a Calendar and button in the end of the page . When you press the Button, the Modal working normally and this is what i want to do

( but when I click on the event in the calendar, not when I click the button )

so then i will be able to popup the current event information in the Modal.

i used testClick() function with $("#myModal").modal("show"); as it showen in Bootstrap Doc, but it doesn't work.

Is there any direct way to run the bootstrap modal with an external function ?

Thank you

Upvotes: 2

Views: 132

Answers (1)

Ranny
Ranny

Reputation: 136

Thank for all who try to help i found a nice easy way to solve this trick, it is just kind of twisting but it solve my problem.

i gave the Modal button an id="datepicker" and i clicked this button in my function like so .

testClick() {
 $("#datepicker").click()
}

and wow the Modal run normally.

The https://codesandbox.io/s/3nkq5zwy6 has been uapdated too .

Have a nice coding ^_^

Upvotes: 1

Related Questions