Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I want to open jquery colorbox on button click.
But it is giving error. I searched on net for this- all are directing to jquery version problem.
But i have single jquery file still it is giving error.

Below is my code to open colorbox-


C#
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/jquery.colorbox_assessment.js" type="text/javascript"></script>
<script>
		$(document).ready(function(){
		$(".ajax_assessment").colorbox({iframe:true, width:"60%", height:"50%", overlayClose:false, escKey:false});	
		});
</script>



Error is-
Uncaught TypeError: Object [object Object] has no method 'colorbox'
(anonymous function) index.aspx:129
c jquery.js:7341
p.fireWith jquery.js:7403
b.extend.ready jquery.js:6875
H
Posted
Comments
Zafar Sultan 1-Nov-13 8:08am    
You will have to include all the relevant js files with the plugin you are using.

1 solution

Please try this code...

XML
<html>
<head id="Head1" runat="server">
    <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        function colorboxShow() {
            $("#colorbox").show();
        }
        function colorboxHide() {
            $("#colorbox").hide();
        }

        $().ready
        (function () {
            $("#colorbox").hide();
            $('#btnShowColorbox').click(colorboxShow);
            $('#btnHideColorbox').click(colorboxHide);

        })


    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span id="Span2">Show-Colorbox</span><br />
        <span id="Span3">Hide-Colorbox</span>
    </div>
    <div id="Div1" style="width: 100px; height: 50px; background-color: Gray;">
        Welcome to Color Box!
    </div>
    </form>
</body>
</html>



JQuery ColorBox, you need to use the proper Script Files that you can download and add in your application.

JQuery-ColorBox[^]

Thanks!
 
Share this answer
 
v2
Comments
Zafar Sultan 1-Nov-13 8:06am    
Where did you copy this code from? Have you tried it? It won't work I suppose. BTW, the OP's problem is something else. Might be using a plugin...
[no name] 3-Nov-13 22:52pm    
Its not a copied once, I tried myself & tested also.
It worked for me.
[no name] 3-Nov-13 22:53pm    
Hi,
Here I was using the HTML Div Popup option, rather than a Jquery built in Colorbox option.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900