0
votes

I'm trying to set up a jQuery Dialog box from clicking a list element in my navigation bar. I have the code working for a separate project when clicking a canvas element but it wont work for this application. My code is as follows:

Clickable Div in Nav-Bar List:

<nav id="nav_bar">
    <ul>
        <li><a class="fancypdf" href="img/resume.pdf">Resume</a></li>
        <li><a>Youtube</a></li>
        <li class="contact" style="cursor:pointer;">Contact</li>
    </ul>
</nav>

Div that Should Show up in Dialog Box:

<div class='dialog'>
    Hello
</div>

jQuery:

<script>
$(function(){
    $(".contact").click(function(event){
        $(".dialog").dialog({
            width:490,
            height:500,
            draggable:false,
            blur:true,
            show:{
                effect:"blind",
                duration:100
                },
    hide: {
    effect: 'blind',
    duration: 100
    }
        });
});
});
</script>

My "imports": http://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'> http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js">    </script>

<script type="text/javascript" src="js/libs/fancybox-2.1.4/jquery.fancybox.pack.js">    </script>
    <link rel="stylesheet" href="css/fancybox/jquery.fancybox-buttons.css">
    <link rel="stylesheet" href="css/fancybox/jquery.fancybox-thumbs.css">
    <link rel="stylesheet" href="css/fancybox/jquery.fancybox.css">

Here is all of my main script tags:

<script>
$(".fancypdf").click(function(){
$.fancybox({
type: 'html',
autoSize: false,
content: '<embed src="'+this.href+'#nameddest=self&page=1&view=FitH,0&zoom=80,0,0"    type="application/pdf" height="99%" width="100%" />',
beforeClose: function() {
$(".fancybox-inner").unwrap();
}
}); //fancybox
return false;
}); //click
</script>


<!-- Grab Google CDN's jQuery, fall back to local if offline -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">  </script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-  1.7.1.min.js"><\/script>');</script>


<!-- FancyBox -->
<script src="js/fancybox/jquery.fancybox.js"></script>
<script src="js/fancybox/jquery.fancybox-buttons.js"></script>
<script src="js/fancybox/jquery.fancybox-thumbs.js"></script>
<script src="js/fancybox/jquery.easing-1.3.pack.js"></script>
<script src="js/fancybox/jquery.mousewheel-3.0.6.pack.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$('.fancybox').fancybox({
beforeShow : function(){
this.title =  this.title + " - " + $(this.element).data("caption");
}
});
}); // ready
</script>



<script type="text/javascript">
$(document).ready(function() {
$(".various").fancybox({
maxWidth    : 800,
maxHeight   : 600,
fitToView   : false,
width   : '70%',
height  : '70%',
autoSize    : false,
closeClick  : false,
openEffect  : 'elastic',
closeEffect : 'none',
beforeShow : function(){
this.title =  $(this.element).data("caption");
}
});
});
</script>

<script>
var jquery = jQuery.noConflict();
jquery(function(){
jquery(".contact").click(function(event){
console.log("clicked");
jquery(".dialog").dialog({
width:490,
height:500,
draggable:false,
blur:true,
show:{
effect:"blind",
duration:100
},
hide: {
effect: 'blind',
duration: 100
}
    });
});
});
</script>
1
Your code is working fine.. just make sure the js are loaded properly.. check jsbin.com/pinifi/1/edit for demomohamedrias
i am clicking the link for resume and it's going to something that states: "You're page is not here."A.Sharma
I added what I have loaded.A.Sharma
you have binded the click event only for "contact" link not for resume linke that's why its taking you to different pagemohamedrias
ah I see but its still not working for me, I copied your code in a separate project and it works there too. It's not my computer, do you think it could be what I've loaded up? Could the loading of the fancybox files be messing with my jQuery loads?A.Sharma

1 Answers

0
votes

It looks like you forgot to include jQuery UI or the order of jQuery and jQuery UI loaded are wrong.

Your code is working fine.

Tested in jsBin

Just make sure all js are included properly:

<link href="http://code.jquery.com/ui/1.9.2/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>