Trigger Modal with a function

4 replies · opened May 19, 2020

SsuppenhuhnMay 19, 2020

Hi!
I need to trigger a model ( #MyModal ) from inside a WebGL Application.
I've tried to call it in a "bootstrap style":
$('#myModal').modal();
But i doesn't trigger that modal - the screen got darkened but the modal doesn't show up.
$.magnificPopup.open('myModal1'); throws an Type Error: c is undefined.
Is in canvas a different function called to trigger a modal ?

Would be awesome if you know a solution :-D

SSemicolon WebSTAFFMay 19, 2020

Hello,

The JS Method for Triggering Bootstrap Modal is:


$('#myModal').modal('show');

and the JS Method for Magnific Popup is:


$('.myModal1').magnificPopup('open');

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

SsuppenhuhnMay 19, 2020

Thanks for the quick response :-) Both methods don't work unfortunately ...hmmm

Just to be sure because i'm probably the worst JS Coder on earth:

I've made the HTML stuff with canvas ( inclusive the modal ):

The Modal works fine when opening as usual:

a href="#myModal1" data-lightbox="inline" class="button button-large button-rounded">Modal

			
				
					
						... my modal stuff
					
					
						[close](#)
					
				
			

Trying to open it via Script ( within my HTML Code NOT from my WebGL App! ) - Bootstrap Style: darkened screen but no modal, JS method throws a Script Error

Boot Style
JS Style

function goModalBoot(){
			$('#myModal1').modal('show');
		}
function goModalJS(){
			$('.myModal1').magnificPopup('open');
		}
SsuppenhuhnMay 20, 2020

Got it finally running. Your JS Method works fine when using "pure" bootstrap code for the modal - awesome!!


Open Modal

  

    
    
      
        ×
        Modal Header
      
      
        
Some text in the modal.

      
      
        Close
      
    

  

While modals from the canvas modals template won't - strange.

Thanks for your help!

SSemicolon WebSTAFFMay 20, 2020

Hello,

Our Templates are using the Non-Modified version of the Modals and the codes should work fine even with the Canvas Package Codes. Simply make sure that you change this value: $('#myModal') to its appropriate Selector Target of the Modal, so that everything works fine.

Hope this Helps!

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard