Home › Forums › JavaScript › Insert code
- This topic is empty.
-
AuthorPosts
-
June 10, 2016 at 9:39 am #242719
Bigg
ParticipantHello!
Mission: when you click X in the popup window – it will fire the cookie code.
Please help me to insert correctly part of cookie code! From this:
<script type=”text/javascript”>
$(window).load(function() {
var hideTheModal = $.cookie(‘hideTheModal’);
if(hideTheModal == null){
setTimeout(function(){
$(‘#opn-win’).modal();
$(‘.close-modal’).click(function(){ // Button X. Link to .close-modal class
// add cookie
$.cookie(‘hideTheModal’, { expires: 30, path: ‘/’ });
});
}, 7000);
}
});</script>To this:
<script type=”text/javascript”>
jQuery(document).ready(function() {
jQuery(‘#myModal’).reveal();
});</script>June 10, 2016 at 9:47 am #242721rkieru
ParticipantMarkdown will help you format that in a much more readable fashion. Based on the code you’ve provided, can I assume correctly that you are relying on Foundation to power your modal?
If so, I assume this solution would work.
jQuery(document).ready(function() { jQuery('#myModal').reveal({ "closed": function () { $.cookie('hideTheModal', { expires: 30, path: '/' }); }); });
June 10, 2016 at 10:23 am #242730Bigg
Participantrkieru, ye, Foundation!
If you don’t mind, can you tell me please hot to insert options of this modal to your code?June 10, 2016 at 12:54 pm #242732rkieru
ParticipantI would suggest adding this into your code:
closed: function () { $.cookie('hideTheModal', { expires: 30, path: '/' } }
It’s really nothing more than adding another option to the list of options you have present, but I cannot test it as I have no real practice with Foundation.
June 12, 2016 at 6:11 am #242752Bigg
ParticipantOk, thanx! But is it possible to insert options in code?
April 19, 2017 at 6:07 am #242825rkieru
ParticipantI don’t fully understand your question. The code I presented above as needing to be added into your script IS an option:
closed
is an option for Foundation’s “Reveal” feature.$('#myModal').reveal({ animation: 'fadeAndPop', animationspeed: 300, closeonbackgroundclick: true, dismissmodalclass: 'close-reveal-modal', //the class of a button or element that will close an open modal closed: function () { $.cookie('hideTheModal', { expires: 30, path: '/') } } });
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.