I am calling a modal Pop Up with a HREF and when I click it is supose to call a Modal but it is only making my background grey and it doesn't show nothing.
I have the following code:
<div class="modal fade" id="test" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
HELLO MY PEOPLE
</div>
</div>
</div>
</div>
The HREF click:
Am I doing something wrong? It's my bootstrap CSS messed up? When I change the modals to Containers it shows, but it Shows in a bad way and I really need the modals, am I doing something wrong?
The code which used itself should work fine without any issues. Add the data-target attribute to your anchor tag and see if it works.
Change your anchor tag code as I mentioned below. This should work fine.
I tested in my local machine and it works fine, but some CSS properties can create a problem like that.
please check some steps
your z-index is greater than your body or parent tag
you have data-target property in your anchor tag
must include jquery & bootstrap.js script in your file
WORKING EXAMPLE
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<div class="modal fade" id="test" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Stackoverflow</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
HELLO MY PEOPLE
</div>
</div>
</div>
</div>
Open Modal
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
You can open modal by using data-target:
Related
I've been trying to build a customize bootstrap theme without success. I want just the Modal component. For that, I'm using Bootstrap 4 and I did the following:
I installed bootstrap library through NPM within my project
(simple web page)
Created 2 css files: mine.css and mine.scss.
Imported the necessary (I think) modules for just Modal component.
I run the code "sass mine.scsss mine.css" into the shell
Then it works, but not the transition effect. It seems like something is missing. Here is my code:
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>Modal</title>
<link rel="stylesheet" href="mine.css">
</head>
<body>
MORE INFORMATION
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">More information</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Coming soon!
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.js"
integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
</body>
</html>
mine.scss
// Required
#import "node_modules/bootstrap/scss/functions";
#import "node_modules/bootstrap/scss/variables";
#import "node_modules/bootstrap/scss/mixins";
// Modal
#import "node_modules/bootstrap/scss/modal";
#import "node_modules/bootstrap/scss/buttons";
Here is an example.
You need to add https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/scss/_transitions.scss because it hosts the fade class modals are using
The classes used are .fade .fade.in and .show
I am new to Joomla, I need to build a simple page that contains logos, when clicking any of the logos I need to see pop up message with description of the logo I clicked, close button should also be included.
You can use Bootstrap for this.
In your template you should include jQuery and Bootstrap 4. You can do it by adding in your /templates/your_theme/index.php the following:
<?php
$doc->addScript('https://cdn.jsdelivr.net/npm/jquery#3.5.1/dist/jquery.min.js', 'text/javascript');
$doc->addScript('https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js', 'text/javascript');
$doc->addStyleSheet('https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css');
$doc->addScript('https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js', 'text/javascript');
?>
Then you can use simple Boorstrap 4 modal, like this
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/js/bootstrap.min.js"></script>
<!-- Button trigger modal -->
<div class="your-any-logo-class" role="button" data-toggle="modal" data-target="#exampleModal">
Put your logo here
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Modal description
</div>
</div>
</div>
</div>
More about Bootstrap 4 modal here https://getbootstrap.com/docs/4.0/components/modal/#live-demo
When I click link,
<a href="#" data-toggle="modal" data-target="#report">
It shows modal well in 1-2 seconds but after that, the modal load page again. So, the content of modal is replaced by the page it loaded. Why?
<div id="report" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</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>
This is probably because you are using the a tag with a href attribute to open the modal. It will then replace the modal with the content of your href, which is the current page. Try to use a button or something to open your modal:
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#report">Launch modal</button>
EDIT: for the ones that don't believe this is possible and are downvoting me, here is jsfiddle with shows exactly the same behavior that #thai6070 is describing in his question.. This option is deprecated in newer versions of bootstrap.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
Paste this code into your head tag.
I'm trying to use a button inside a bootstrap modal to link to another page on my site. I haven't been able to do this for some reason. Here is what the code inside the modal looks like:
<div class="modal-footer">
Read More
<button type="button" data-dismiss="modal" class="btn btn-warning">Close</button>
</div><!-- End modal-footer -->
Clicking on the Read More button will close the modal, but not open the link to another-page.php. Is there another tag that I'm missing?
use this command instead of data-dismiss="modal" in link
onclick="$('#modalId').modal('hide')"
Remove the data-dismiss="modal" attribute from your button...
<div class="modal-footer">
Read More
<button type="button" data-dismiss="modal" class="btn btn-warning">Close</button>
</div><!-- End modal-footer -->
Example...
$('#openBtn').click(function(){
$('#myModal').modal({show:true})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
Open modal
<div id="myModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>Modal header</h3>
</div>
<div class="modal-body">
<p>My modal content here…</p>
</div>
<div class="modal-footer">
Read More
<button class="btn" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
I am making signup/login popup in menu and loading content through file. MY problem is when I try to access popup content from other file popup is not appear.(in other words access content through remotely)
Here is my code
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<li><i class="fa fa-users"></i>Sign Up</li>
On other file code where popup content is add
<div class="modal fade" id="signup-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header signup_modal_header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h2 class="modal-title" id="myModalLabel">Registration Form</h2>
</div>
<div class="modal-body signup-modal">content</div>
</div>
</div>
</div>