How can I show modality in twitter bootstrap only once?
now this is my code:
<script type="text/javascript">
$(document).ready(function() {
if($.cookie('msg') == 0)
{
$('#myModal').modal('show');
$.cookie('msg', 1);
}
});
</script>
The model loads on the page, but when I update it, it shows that it should only show once. $ .cookie - https://github.com/carhartl/jquery-cookie
update:
This worked: "hide" does not work for some reason
<script type="text/javascript">
$(document).ready(function() {
if($.cookie('msg') == null)
{
$('#myModal').modal('show');
$.cookie('msg', 'str');
}
else
{
$("div#myModal.modal").css('display','none');
}
});
</script>
@SarmenB Update worked in most browsers (FF, IE9), but not in IE8.
I changed my updated solution to make it work in IE8 ...
This was @SarmenB's solution:
<script type="text/javascript">
$(document).ready(function() {
if($.cookie('msg') == null)
{
$('#myModal').modal('show');
$.cookie('msg', 'str');
}
else
{
$("div#myModal.modal").css('display','none');
}
});
</script>
This is a modified solution that I came across with the fact that IE8 works :
<script type="text/javascript">
$(document).ready(function() {
if($.cookie('msg') != null && $.cookie('msg') != "")
{
$("div#myModal.modal, .modal-backdrop").hide();
}
else
{
$('#myModal').modal('show');
$.cookie('msg', 'str');
}
});
</script>
, IE8, , if/else.