SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2009
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Jquery Code Not working - Missing something?

    I found this code but can't get it to work. Can someone point out where I'm going wrong.
    In head of document
    Code:
    <script src="jquery/jquery.js" type="text/javascript"><!--mce:0--></script>
    <script src="jquery/ui.core.js" type="text/javascript"><!--mce:1--></script>
    <script src="jquery/ui.dialog.js" type="text/javascript"><!--mce:2--></script>
    <script language="javascript" type="text/javascript">
      $(document).ready(function() {
          $(".sectionHelp").click(function(){
          $("#dialog_"+$(this).attr('id')).dialog({autoOpen: false});
          $("#dialog_"+$(this).attr('id')).dialog("open");
    	});
    });
    </script>
    In body of document.
    Code:
    <div class="dialog" id="dialog_help1" title="Dialog Title 1">
     <p>Dialog 1</p>
    </div>
    <div class="dialog" id="dialog_help2" title="Dialog Title 2">
     <p>Dialog 2 </p>
    </div>
        <a href="#" id="help1" class="sectionHelp">Help1</a>
        <a href="#" id="help2" class="sectionHelp">Help2</a>
    Thanks in advance.

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,491
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    What should it do? And what does it do? Or doesn't it do anything?

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2009
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops. Sorry guido. It's supposed to allow me to open up dialog help boxes when the anchor is clicked. Also I failed to show the css hiding the div as follows.
    Code:
    div.dialog{
             display:none;
             }

  4. #4
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You didn't answer the question "what does it do now?" The code you've posted works for me. Check your JavaScript console.

  5. #5
    SitePoint Zealot
    Join Date
    Sep 2009
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm very sorry about not being more specific. I was dealing with interruptions and with this code. The code is not doing anything when I click on either link. I'm not that familiar with javascript so I do not know what the JavaScript Console is or what I can do for me. Javascript is turned on and working. I've tried with the script in the head and in the body. I've tested that jquery.js is being used by the page with an test alert. Can you point the way to how the console may work for me?
    Thanks

  6. #6
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, that's helpful. How you get to the JS console depends on which browser you're using. In Firefox and Chrome, it's Ctrl+Shift+J. If you're in another browser, Google can tell you how to do it.

    See if there are any errors listed there. Perhaps the versions of jQuery and jQuery UI you're including are out of sync with one another? That's happened to me before. If it's not that, then it's probably some other part of your JS or CSS that's interfering somehow. If you want to post the whole thing or a link to it, someone may be able to tell you more.

  7. #7
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,990
    Mentioned
    186 Post(s)
    Tagged
    2 Thread(s)
    Forgive me for what may be a silly question, but if you are using CSS to render the div as display: none, you are changing that when it opens, correct?

  8. #8
    SitePoint Zealot
    Join Date
    Sep 2009
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestion about looking at the console. It did show some errors and I thought maybe I was missing something, so I added this line to the head and it works fine.
    Code:
    <script src="jquery/jquery-ui-1.8.5.custom.min.js" type="text/javascript"><!--mce:1--></script>
    Thanks for your time.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •