The MU forums have moved to WordPress.org

Dismiss a notice in the UI (1 post)

  1. Romik84
    Member
    Posted 14 years ago #

    Hi there,

    I just try to figure out a function which will dismiss a text and saves it in cookies for next page reload/visit. My current code looks as follow:

    <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="jquery.cookie.js" type="text/javascript"></script>
    
    <script>
    $(document).ready(function() { 
    
    			$.cookie("viewState");
    
    			var theState = $.cookie("viewState");
    
    			$("#R1").click(
    				function () {
    					$("#secret").hide("slow");
    
    					$.cookie("viewState", "none");
    					theState = "none"
    			});
    
    			$("#secret").css('display', theState);
    
    		});
    		</script>

    and the message for dismissing:

    <div id="secret" style="display:none;" class="theme"><p>Test
    
      <a href="#" class="button" id="R1">Done</a>
    
      </p>
    </div>
    
    <script>
    
        $("a.button").click(function () {
          $("div.theme").hide("slow");
          $(this).hide();
    
          return true;
        });
    </script>

    The function is working but it takes a second while it dissapeared after page is loaded. Is possible to work faster or would be better to save it to a blog table? If yes, how? Thanks

About this Topic

  • Started 14 years ago by Romik84