简体   繁体   中英

Dynamic bootstrap modal. 3 button 1 modal

i want to Single modal trigger with multiple buttons.

my buttons;

<button data-toggle="modal" data-target="#mod-primary" type="button" class="btn btn-space btn-warning">Button 1</button>
<button data-toggle="modal" data-target="#mod-primary" type="button" class="btn btn-space btn-warning">Button 2</button>
<button data-toggle="modal" data-target="#mod-primary" type="button" class="btn btn-space btn-warning">Button 3</button>

Just i want to add variable. example; ?link=1

<button data-toggle="modal" data-target="#mod-primary?link=1" type="button" class="btn btn-space btn-warning">Button 1</button>

i ask this cause in modal i have a form, hidden field

Here is simple example shown three button trigger single Modal

 <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h2>Modal Example</h2> <!-- Trigger the modal with a button --> <!-- first --> <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Button 1</button> <!-- sec --> <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Button 2</button> <!-- third --> <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Button 3</button> <!-- Modal --> <div class="modal fade" id="myModal" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Modal Header</h4> </div> <div class="modal-body"> <p>Some text in the modal.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> </div> </body> </html> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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