Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple instances of modaal issue #134

Open
yosypandriyash opened this issue Nov 2, 2020 · 3 comments
Open

Multiple instances of modaal issue #134

yosypandriyash opened this issue Nov 2, 2020 · 3 comments

Comments

@yosypandriyash
Copy link

When I create more than a single Modaal instances, something goes wrong. When I close the second or the third instance with X close button, the previous modaal not works, I can't close it, when i do console.log(self.scope.id) it show always the last created modaal id and it no change.
Thanks!

@MikeiLL
Copy link

MikeiLL commented Nov 17, 2020

You should probably share your code.

@yosypandriyash
Copy link
Author

I had to change the library to generate the modals because I was in a hurry to finish the project, however it is as simple as declaring two different instances of modaal. Something like:

$ ('. my-first-selector'). modaal ({args});
$ ('. my-second-selector'). modaal ({args});

The error occurs when I open the modal $ ('. my-first-modal') and then, without closing the first one, I open the modal $ ('. my-second-modal');

It allows me to close the last one but afterwards the first one cannot be closed anymore.
Thanks!!

@graemebryson
Copy link

I'm experiencing the same issue — I have a global modal, in which there's a link to launch a second (video) modal on top. I can close the video modal, but the original modal then fails to close at all and I need to refresh.

I've tried forcing it via callbacks on the second modal, but it ends up launching multiple instances of the first.

// Initialize first modal
// --------------------------------------------------

jQuery(function($){
	$('.trigger__modal--first').modaal({
		custom_class: 'modal--first'
	});
});


// Initialize second modal
// --------------------------------------------------

jQuery(function($){
	$('.trigger__modal--second').modaal({
		custom_class: 'modal--second',
		type: 'video',
		after_open: function() {
			$('.trigger__modal--first').modaal('close');
		},
		after_close: function() {
			$('.trigger__modal--first').modaal('open');
		}
	});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants