I've checked my code and it works fine but for some reason I cannot open Dialog once it was closed. Any advice on why is that?
The code is here - http://jsfiddle.net/EA2Dg/1/
Why don't you use "click function to open the dialog, it should work
HTML
<div id="dialog" title="Basic dialog">
<p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<button id="opener">Open Dialog</button>
JQuery:
<script>
$(function(){
$("#opener").click(function(){
$("#dialog").dialog();
});
});
</script>
Related
I am working in a foundation frame work for responsive.
on click of a link say
Click Me For A Modal
<div id="myModal" class="reveal-modal" data-reveal>
<h2 id="modalTitle">Awesome. I have it.</h2>
<p class="lead">Your couch. It is mine.</p>
<p>I'm a cool paragraph that lives inside of an even cooler modal. Wins! </p>
<a class="close-reveal-modal" aria-label="Close">×</a>
</div>
I want as the window opens the focus is given to the myModal.
i am trying
$('a.button').on('click', function() {
$("#myModal").attr("tabindex","0").focus();
});
but it not working.
My script is running before the modal window opens and thus there is no such element available to receive focus.
You can set the focus on the whole modal.
$('a.button').on('click', function() {
$("#myModal").focus();
});
Is this what you where looking for?
I would like to get a lightbox modal box to pop up automatically on page load.
My current anchor works perfect when I actually click it, and here is my bit of JQuery that I've been using so far.
<script>
$(document).ready(function(){
document.getElementById('popup').click();
});
</script>
And the HTML
<a id="popup" class="wb-lbx lbx-modal" href="#alert">test</a>
<section id="alert" class="mfp-hide modal-dialog modal-content overlay-def">
<div class="alert alert-info">
<h2 class="h4">header</h2>
<p>content</p>
</div>
</section>
Problem is, it just brings me to the #popup anchor location on the page, not actually triggering the lightbox that pops if you were to actually click it.
How do I trigger the click event on page load?
Thanks
I am using a modal that I used from a previous site where it works fine. Difference is this modal will only appear in IE9 only to direct users to a better browser. I was able to test it with just a alert and works fine.
However, for some reason, when I transfer the code I did for a previous site to this new site, the Modal isn't responding and to one point is not showing on the site.
When I try close the "Close" button, it will just refresh the page. I am not sure why and when I close the "X" button, it does not work either.
The code is inserted in a coldfusion file and I am not sure if it causing conflict or not.
Any help would be appreciated.
Here is what I did for the modal. ie-only detects whether it is IE9 or not:
<!---<div class="ie-only" style="overflow-y:hidden;">
<div class="modal fade in" id="myModal" aria-hidden="false" style="display:block; padding-right:17px;">
<div class="modal-dialog modal-md custom-height-modal">
<div class="modal-content">
<div class="modal-header" style="background-color:##428bca">
<button type="button" class="close" data-miss="modal">x</button>
<h3 class="modal-header" style="background-color:##428bca; text-align:center">Attention</h3>
</div><!---Modal-Header Div--->
<div class="modal-body">
<p style="text-align:center">You are using an outdated browser.<br /> <br /> Upgrade your browser today to better experience this site.</p>
</div><!---Modal-Body Div--->
<div class="modal-footer">
<p class="text-center"><a class="btn btn-default" data-dismiss="modal">Close</a></p>
</div><!---Modal-Footer Div--->
</div><!---Modal-Content Div--->
</div><!---Custom Height Div--->
</div><!---Modal Fade in Div--->
</div><!---Start of Modal Div--->
<!--End of Modal container--> --->
<!---<script>
$(function(){
$('##myModal').modal('show');
}
</script>
<div class="modal-backdrop fade in"></div>--->
It looks like there is a syntax problem in your code:
$(function(){
$('##myModal').modal('show');
}
This is incorrect; it should be:
$(function(){
$('#myModal').modal('show');
});
When corrected the Modal loads as a Modal, which in turn causes the Close button to operate as expected. Absent this the modal still loads (because you have in activated) but loads absent the overlay and absent the hook to Bootstrap's Modal JS which explains why your close button is non-functional.
You can see a functional example here: http://www.bootply.com/24IPYP8O3F
Why your code isn't working
The in class on your Modal div instructs Bootstrap to make that modal visible, and position it according to the Bootstrap CSS. Your jQuery is wrong though, so Bootstrap treats this like a bit of HTML that is just part of the document.
Once you correct your jQuery Bootstrap processes it as expected; as a Modal Javascript component. Once that happens it is presented with the overlay (as default) and the data-dismiss attributes are processed correctly.
The short of it is that the entire issue for why your Modal is not behaving like a Modal is that your jQuery is wrong.
This question already has answers here:
Nifty Modal - how to trigger a modal without a button
(7 answers)
Closed 7 years ago.
I want to show my nifty window modal popup on page load. This is my nifty window popup modal code:
<div class="md-modal md-effect-1" id="modal-1">
<div class="md-content">
<h3>Modal Dialog</h3>
<div>
<p>This is my first nifty modal window. </p>
<button class="md-close">Close me!</button>
</div>
</div>
</div>
Thanks in advance.
I've looking in to the source code of the demos, and I believe that this would do the trick:
$(function() {
$('#modal-1').addClass('md-show');
});
I have been working with foundation 5, the reveal modal does not trigger and I'm totally at a loss.
Here's the modal code
<td>
Delete
<div id="modal" class="reveal-modal medium" data-reveal>
<p></p>
<p>Please confirm</p>
<a class="button radius">Confirm</a>
<a class="close-reveal-modal">x</a>
</div>
</td>
And the order of the scripts is in the right order just before closing the body tag.
<script src="/js/vendor/modernizr.js"></script>
<script src="/js/vendor/jquery.js"></script>
<script src="/js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
I have tried to wrap the $(document).foundation(); in $(document).ready(function(){, but nothing is happening. The alert boxes work just fine, so I'm baffled by the problem with reveal modals.
Any help would be appreciated. Thanks.
The reason this happening, is perhaps because the modal should be the direct child of the "body" element. It should not be part of the "td" element.
I found the answer on this page:
http://foundation.zurb.com/forum/posts/20051-foundation-5-reveal-modal-doesnt-open