Reset After Function Completed?

Discussion in 'jQuery' started by scottlpool2003, Oct 2, 2012.

  1. #1
    I'm using JQuery to throw out a nice error message which fades and vanishes on click.

    Problem is, this error message is used for a variety of things, but it only works once.

    e.g. user has to be logged in to do something, but I show the button to do it anyway in order to entice users to signup. When they click the button if they're not logged in, an error message shows. There are more than 1 button doing the same thing, but if one button has been clicked, the error message doesn't show again...

    JQUERY:
       <script type="text/javascript">
     
    $(".alerts").click(function () {
       $(this).fadeOut('slow');
    });
     
    $(".fadeInbox").click(function () {
       $(this).hide().fadeIn(2000);
    });
     
    $(".fadeTobox").click(function () {
       $(this).fadeTo('fast',0.2);
    });
     
    $("#reset").click(function(){
    	location.reload();
    });
    
    $(document).ready(function() {
       
        $('a[href=#top]').click(function(){
            $('html, body').animate({scrollTop:0}, 'slow');
            return false;
        });
    
    });
    </script>
    Code (markup):
    BUTTONS:
    	<div class="greybuttons">
    <?php 
    	if ($notloggedin == "true"){
    	  echo "<a href=\"#\" class=\"fav\" title=\"Add Magazine to your favorites\" id=\"attach_box\"></a><a href=\"#\" class=\"wish\" title=\"Mark this issue to read later\" id=\"attach_box\"></a><a href=\"#\" class=\"remove\" title=\"Flag this publication\" id=\"attach_box\"></a>";
    }
    else {
    	 echo "<a href=\"addfav.php?id=$id&uid=$user_id\" class=\"fav\" title=\"Add Magazine to your favorites\" ></a><a href=\"readlater.php?id=123&uid=321\" class=\"wish\" title=\"Mark this issue to read later\"></a><a href=\"readlater.php?id=123&uid=321\" class=\"remove\" title=\"Flag this publication\"></a>";
    }
    ?>
    	</div>
    	<div class="read_more">
    
    <?php 
    	if ($notloggedin == "true"){
    	  echo "<a href=\"/uploader/file/$pdf\" target=\"_blank\" title=\"Read Issue $issue_number of $main_title\" class=\"readnow\" id=\"attach_box\"></a>";
    }
    
    else {
    	  echo "<a href=\"/uploader/file/$pdf\" title=\"Read Issue $issue_number of $main_title\" class=\"readnow\" target=\"_blank\"></a>";
    }
    ?>
    Code (markup):
    Is there any way to completely reset the function once it's been clicked?
     
    scottlpool2003, Oct 2, 2012 IP
  2. Wogan

    Wogan Peon

    Messages:
    81
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    0
    #2
    There's nothing in your sample code that includes an error message, or any HTML that references that jQuery, so I'm not sure I can help...
     
    Wogan, Oct 17, 2012 IP
  3. scottlpool2003

    scottlpool2003 Well-Known Member

    Messages:
    1,708
    Likes Received:
    49
    Best Answers:
    9
    Trophy Points:
    150
    #3
    I pasted the entirely wrong code!

     
    scottlpool2003, Oct 18, 2012 IP