tags:

views:

434

answers:

2

I am going to use Facebox in my page, and am loading following plugins:

<script type="text/javascript" src="facebox.js"></script>
<script language="javascript" src="jquery-min.js"></script>
<link type="text/css" href="facebox.css" rel="stylesheet" />

I have two div elements. I want to show one div in the facebox after an onclick event, and I'm using this command after the onclick event

jQuery('#dialog-form').facebox()

dialog-form is the div id to show in the Facebox, but it's showing the two divs in the page and Facebox is not appearing. How can I achieve this?

+4  A: 

It might be that you need to include the jQuery file before the plugin:

<script type="text/javascript" src="jquery-min.js"></script>
<script type="text/javascript" src="facebox.js"></script>
nickf
+1  A: 

Be sure to reference jQuery first. The following worked for me just fine:

<html>
  <head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
    <script type="text/javascript" src="facebox/facebox.js"></script>
    <link rel="stylesheet" type="text/css" href="facebox/facebox.css" />
  </head>
  <body>
    <a href="#dialog-form" rel="facebox">text</a>
    <div id="dialog-form" style="display:none">
      <form method="post">
        <p><label>Username:</label> <input type="text" name="user" /></p>
        <p><input type="submit" /></p>
      </form>
    </div>
    <script type="text/javascript">
      $(function(){
        $('a[rel*=facebox]').facebox()
      });
    </script>
  </body>
</html>
Jonathan Sampson