Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you're looking for the .close method - here's how you'd use it, after the user has pushed the button to submit their age:</p> <pre><code>$('#dialog-modal').dialog('close'); //hides modal, shows content behind </code></pre> <p>More documentation on jQuery UI dialogs:</p> <p><a href="http://api.jqueryui.com/dialog/#method-close" rel="nofollow">http://api.jqueryui.com/dialog/#method-close</a></p> <hr> <p>EDIT: Here's how you could update your start() method:</p> <pre><code> start: function() { this.setUsersBirthday(); if (this.userIsOverMinimumAge()) { this.setCookie("usersBirthday",this.usersBirthday,30); $('#dialog-modal').dialog('close'); } else{ this.notMinimumAge(); }; }, </code></pre> <p>And a JSFiddle Demo: <a href="http://jsfiddle.net/donmccurdy/czERa/" rel="nofollow">http://jsfiddle.net/donmccurdy/czERa/</a></p> <hr> <p>EDIT #2 - (Responding to OP's question about checking the cookie on every page)</p> <p>You had a few bugs in the code that checks the cookie. I've updated the JSFiddle, and here's a quick version of what was wrong:</p> <p>1) Instead of the code you currently have that always shows the dialog, check the cookie first. Like this:</p> <pre><code>$(function() { window.ageCheck.checkCookie(); }); </code></pre> <p>2) Update checkCookie() method to show the dialog when necessary:</p> <pre><code>checkCookie: function () { var usersBirthday=this.getCookie("usersBirthday"); if (!usersBirthday) { // unknown age - show dialog. $( "#dialog-modal" ).dialog({modal: true}); return; } this.usersBirthday = new Date(usersBirthday); if (this.userIsOverMinimumAge()) { $('#dialog-modal').hide(); // user is &gt; 13, don't show dialog. } else { // user is &lt; 13, redirect to another page. this.notMinimumAge(); } } </code></pre> <p>3) You have a bug in your getCookie method, as you were returning "usersBirthday" instead of the birthday itself. Fixed here:</p> <pre><code>getCookie: function (c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i&lt;ARRcookies.length;i++) { //split on '=', then check cookie x=ARRcookies[i].split('='); if (x[0]===c_name){ return unescape(x[1]); } } }, </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload