Reputation: 159
I am aware this question has been asked many times but I just cannot seem to get this to work because of my almost null JS knowledge.
I am using the Zebra Dialog jquery plugin to make a modal window that I want to open when the page is loaded.
All the examples on the Zebra Dialog website only explain how to load the modal when clicking a link, but I just cannot seem to get it to load on page load.
I am using the following code right now:
<script type="text/javascript">
$(document).load(function() {
// show a dialog box when clicking on a link
$(anchor).bind('click', function(e) {
e.preventDefault();
$.Zebra_Dialog('The link was clicked!');
});
});
</script>
I am aware that I am using code for loading the modal when clicking on a link but I have tried a lot of stuff and not found a way to succesfully modify it to load on page load.
Any help would be greatly appreciated!
Upvotes: 1
Views: 2362
Reputation: 1803
Perhaps jQuery is not included? You need jQuery, then the plugin js/css in your <head>
:
<script type="text/javascript" src="path/to/jquery.js"></script>
<script type="text/javascript" src="path/to/zebra_dialog.js"></script>
<link rel="stylesheet" href="path/to/zebra_dialog.css" type="text/css">
and then the the loading code in <body>
(in script tags or loaded from a file)
$(document).ready(function() {
$.Zebra_Dialog('Page loaded!');
});
Upvotes: 1
Reputation: 3719
i would try:
$(document).ready(function() {
$.Zebra_Dialog('Page loaded!');
});
This basically means that once the document is ready (i.e. loaded), open your modal dialog. Previously you had the code saying, when the document is ready attach a handler to the click event of some element (not sure what 'anchor' is in your code), and in that event handler open the dialog.
Upvotes: 0
Reputation: 362
$(document).load(function() {
$.Zebra_Dialog('The link was clicked!');
});
Upvotes: 0