0
<!-- Modal -->
<div id="appsmodal" class="modal hide fade" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>
<script type="text/javascript">
    $(document).ready(function() {

        if($.cookie('msg') == 0)
        {
            $('#appsmodal').modal('show');
            $.cookie('msg', 1);
        }

    });
</script>

I have been mind boggled for about an hour now to no avail. I prefer not to ask questions until I have used all my resources.

Binary101010
  • 580
  • 4
  • 11
  • is this a .length thing? if (!$.cookie('msg').length) or similar? if the cooke 'msg' hasn't been set, it won't equal 0. it just won't exist. – orolo Apr 01 '13 at 19:30
  • .length? huh? jquery cookie.js and bootstrap modal – Binary101010 Apr 01 '13 at 19:32
  • i'm wondering if your if "if($.cookie('msg') == 0) will NEVER return true because if you haven't set $.cookie('msg'), it won't == 0. it just won't exist. but, asking if $.cookie('msg').length == 0 might return what you're looking for. – orolo Apr 01 '13 at 19:34
  • did not work either – Binary101010 Apr 01 '13 at 19:41
  • ok, but first, if you remove the if statement, does the cookie set? say, if you set it to 'foo', instead of 1, can you view it in chrome inspector, or firefox firebug or what have you? also, does your browser console show any errors or messages? – orolo Apr 01 '13 at 19:45

2 Answers2

1

From the docs https://github.com/carhartl/jquery-cookie:

Create session cookie:

$.cookie('the_cookie', 'the_value');
Create expiring cookie, 7 days from then:

$.cookie('the_cookie', 'the_value', { expires: 7 });
Create expiring cookie, valid across entire site:

$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
Read cookie:

$.cookie('the_cookie'); // => "the_value"
$.cookie('not_existing'); // => undefined
Read all available cookies:

$.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" }
Delete cookie:

Have your browser's console open and check for any error statements (are you including the cookie library, for example). Also, use the inspector in your browser to make sure the cookie is actually being set: http://getfirebug.com/cookies

orolo
  • 3,951
  • 2
  • 30
  • 30
1

FINALLY!

I figured it out. Joomla issue

Binary101010
  • 580
  • 4
  • 11