Automatic modal when starting home page

Great @Pealco Thanks so much!

@Pealco The solution is perfect. Now I have an other question. :slight_smile:
Can the model starts after scrolling a bloc?

That would be indeed fabulos…

1 Like

Let me found a way, I’m writing the code…

It works in my head at least. never used the modal but based on @Pealco code above this seems correct.

<script>
$(document).ready(function() {
     // hide modal on page load
     $('#modal-32886').modal('hide');

     // window scroll function
     $(window).scroll(function() {

         //offset the scroll trigger in pixels
         if ($(document).scrollTop() > 100) {
               $('#modal-32886').modal('show');
         }
         else {
               $('#modal-32886').modal('hide');
         }
     });
});
</script>

Changing the scroll top value give you the option to start the modal at a later point on the page. I have such limited time these days, sorry.

Hello @Whittfield is almost that code, but what happened with it is that you enter in a loop situation.

For that condition only happens once, there is the code:

<script>
jQuery(document).ready(function($){

    $triggered_times = 0;

    $(window).on('scroll', function() {
		var y_scroll_pos = window.pageYOffset;
       	var scroll_pos_test = 150;   // set to whatever you want
       	
      	if(y_scroll_pos > scroll_pos_test && $triggered_times == 0 ) {

			$('#modal-32886').modal('show');
				
			$triggered_times = 1;   // to make sure the above action triggers only once

            }
    });

})
</script> 

Hope it replys to your need @RME

hey @Pealco It doesn’t work. I appreciate your support. Thanks.

Hello @RME and did you create the modal with that specific name? Modal-32886?

Sure, i did change the name. In preview mode works fine but not after extracting.

And what your export options?

Hello @RME,

There is your example here:

https://blocs.webtekpc.pt/exemples/rme/

:grinning:

5 Likes

Hey @Pealco now it works fine. I don’t use minify HTML! Thanks

1 Like

In my endless search for web resources I just found a website that may be useful with a free Bootstrap offering. I did wonder if this could be turned into a bric. https://lunar.atomui.com/

4 Likes

That would be an awesome bric as there are some really neat modals.

There is some issue generally with this code provided above. I think there is some issue with jquery.

I get aways the error on console. Not sure why.

Update: i tried for 3 hour to get this modal working. And suddenly it worked from alone. Not sure why.

Some nice Modals. Even if you don’t use these they give you a lot of ideas for using them.

casey

Salut all, I can’t get my head around an issue with automatic modals happening as from Blocs Version 3.2.3 . Automatic modals (I tried all different formats as described above) are not showing up in preview as well as after exporting when created with version 3.2.3 and higher. (including 3.3.0b1). However when opening the Blocs file created (in v3.2.3 or higher) in Blocs 3.2.2 or lower the modal pops up as a charm and exports as well. I’ve filed a bug @norm. Do other users have similar issues?

Many thanks to all contributors on this forum to who keep amateurs like me going.

Jerry

@Pealco,

Hello and thank you for the javascript code solution! I was able to get the ‘ALWAYS START MODAL’ working as it should, but the ‘ONE TIME MODAL WITH COOKIES’ I could not get anything to happen. Do I need to do something (with cookies, etc) to enable that code? I pasted it in the footer section of the page settings. Here’s the exact code I pasted:

Any help greatly appreciated! Thank you!

42%20PM

Please wait for tonight… I will create 6 new snippets all about this… I will publish the snippets in the normal @pealco topic.

Hello @Creative please check the @pealco topic, I create a few modals snippets, and a new snippet, check it please…