Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Need help editing "bios.js" (expanding/collapsing <li>'s)

    Hello everyone!

    I'm newly managing a small college website with next to no experience.

    There is a file called "bios.js" which creates expanding/collapsing li's. The problem is that I've put some hyperlinks into the expanded content, and it seems that "bios.js" is in front of, so clicking the hyperlink simply collapses the list item instead of opening the link.

    Is there any way to:
    a) have the hyperlinks trump the javascript?
    b) Make "bios.js" apply to the title class of the list item rather than the list item itself?

    I'm new to this, so I'm not going to post 100 lines of code before I know if it's doable. And if you reply to this, perhaps you could give me a hint as to what part of the code I should post (the open-hover portion?). Thanks all!

  • #2
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    First of all a link to the site is a good help and you can attache the js file (bios.js) so we can look at it.
    Software and cathedrals are much the same - first we build them, then we pray.

  • Users who have thanked ckeyrouz for this post:

    Dodhner (03-08-2012)

  • #3
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Ok, I've attached the file as a css, and here's the link: http://dev.www.brynathyn.edu/admissions/newstudents

    You'll need a username/password, which I'm not going to post here. email me at dylan.odhner@brynathyn.edu and I'll send username and password.

    Thanks to anyone who is looking at this! -Dylan
    Attached Files Attached Files

  • #4
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    You can send me a temporary username/pwd in the PM (private messaging)
    Software and cathedrals are much the same - first we build them, then we pray.

  • #5
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    The reason of the problem is that an event is attached to the li and that changes the css class when clicking. If it is open then it closes and vice versa.

    Since the anchor element is inside the li it will inherit the onclick event from its parent.

    What I did was to stop the propagation when clicking only on the anchors.

    I have added the following code in the file bios.js

    Code:
    $("a").each(function (i) {
               $(this).click(function(e)
              {
                e.stopPropagation();});
            
        });
    I have tested it on firefox and on IE8 and seems to be working, however it is up to you to decide if this is the way you want it to work or not.

    Let me know what happens.
    Software and cathedrals are much the same - first we build them, then we pray.

  • Users who have thanked ckeyrouz for this post:

    Dodhner (03-08-2012)

  • #6
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Silly question Ckeyrouz:

    Where exactly did you put that code in bios.js? Does it matter?

  • #7
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    It doesn't matter as long as it is inside the main function
    Code:
    $(document).ready(function() {
    Software and cathedrals are much the same - first we build them, then we pray.

  • #8
    New to the CF scene
    Join Date
    Mar 2012
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up Solved! Thank you Ckeyrouz!

    Solved! Thank you Ckeyrouz!

    Simple and effective solution.

  • #9
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    Most welcome. Glad I was able to help.
    Software and cathedrals are much the same - first we build them, then we pray.


  •  

    Tags for this Thread

    Posting Permissions

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