SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist silversurfer5150's Avatar
    Join Date
    Aug 2010
    Posts
    534
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Toggle event not firing first time

    Hi guys,

    My toggle works fine on the button with the id hide_show, however if I close the panel with an alternative button,(close_link) the toggle event thinks its still sending a close command. This means that I must click the button hide_show twice to get the panel to slidedown again.

    What is the best way around this?

    PHP Code:

               
    $("#hide_show").toggle(function()
                 {
                     var 
    src ="image/data/ButtonsGlyphsSymbols/hide_order.png";
            $(
    ".hidden_order_data").slideDown("slow");
            $(
    ".review_order").attr("src"src).animate({height:"61"}, "fast");
                  }
                 ,
                 function()
                 {
                     var 
    src ="image/data/ButtonsGlyphsSymbols/review_order.png";
            $(
    ".hidden_order_data").hide("slow");
            $(
    ".review_order").attr("src"src);
                 }
             );





                $(
    ".close_link").click(function()
                 {
                  var 
    src ="image/data/ButtonsGlyphsSymbols/review_order.png";
                            $(
    ".hidden_order_data").hide("slow");
                   $(
    ".review_order").attr("src"src);
                  }); 
    "Persistence is the path to perfection"

  2. #2
    SitePoint Evangelist silversurfer5150's Avatar
    Join Date
    Aug 2010
    Posts
    534
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Am I right in my diagnosis? Its because toggle wants to fire the events sequentially and having another button hide the panel is disrupting this sequence?

    I know that I can do:
    PHP Code:
              $("#hide_show").click(function()
                 {
                                if(!$(
    ".hidden_order_data").is(':visible'))
                                {
                                  var 
    src ="image/data/ButtonsGlyphsSymbols/hide_order.png";
                          $(
    ".hidden_order_data").slideDown("slow");
                          $(
    ".review_order").attr("src"src).animate({height:"61"}, "fast");
                                }
                                else
                    {
                                  var 
    src ="image/data/ButtonsGlyphsSymbols/review_order.png";
                          $(
    ".hidden_order_data").hide("slow");
                          $(
    ".review_order").attr("src"src);
                     }
                           }); 
    But what if I wanted to keep toggle?
    "Persistence is the path to perfection"


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
  •