Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is data-toggle="modal" used for? [duplicate]

I have a button code which someone created it. Here are the button code:

<button class="demo btn btn-primary" data-toggle="modal" href="#long"  onClick="javascript:add();"><i class="icon-plus-sign icon-white"></i> Add Employee</button>

I've edit the function related to the button (send the new data from the button, and call it in the function), but nothing happened. Then I tried to delete data-toggle="modal", the pop up didn't show. So, I wonder, what is data-toggle="modal" use for?

I thought here are the link to modal:

<script src="js/bootstrap-modalmanager.js"></script>
<script src="js/bootstrap-modal.js"></script>

Can anyone explain me about data-toggle="modal"? Thank you.

like image 329
Lupita Noyra Avatar asked Jun 24 '14 03:06

Lupita Noyra


People also ask

What does data-toggle modal do?

class = "modal-footer", is a CSS class of Bootstrap CSS to set style for footer of the modal window. data-toggle = "modal", HTML5 custom data attribute data-toggle is used to open the modal window.

What is toggle in modal?

toggle() simply shows and hides an element. Bootstrap's . modal() constructs a modal... not the same thing as simply toggling visibility.

What is the use of data-toggle and data-target?

Just add data-toggle="collapse" and a data-target to element to automatically assign control of a collapsible element. The data-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you'd like it to default open, add the additional class in.


1 Answers

From the Bootstrap Docs

<!--Activate a modal without writing JavaScript. Set data-toggle="modal" on a 
controller element, like a button, along with a data-target="#foo" or href="#foo" 
to target a specific modal to toggle.-->

<button type="button" data-toggle="modal" data-target="#myModal">Launch modal</button>
like image 88
Dan Avatar answered Oct 06 '22 02:10

Dan