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

Trigger overflow content check on setContent() #79

Closed
MicahBrown opened this issue Mar 26, 2018 · 6 comments
Closed

Trigger overflow content check on setContent() #79

MicahBrown opened this issue Mar 26, 2018 · 6 comments
Labels

Comments

@MicahBrown
Copy link
Contributor

I'm appending ajax-ed content to the modal using setContent(). The issue is that the content is initially blank when the modal is opened and doesn't overflow the page. However, when the content is added, it overflows the page and the .tingle-modal--overflow class is never added since it only triggers on window resize (as I can see), but not setContent(). I therefore cannot scroll with the content now overflowing the page.

My work around looks something like this:

var modal = new tingle.modal();
modal.open(); // modal content doesn't yet overflow the page at this point since it's blank

$.get('/ajax_content_url', function(response){
  modal.setContent(response) // modal content now overflows page, but I can't scroll since there's no .tingle-modal--overflow in the modal classes
  modal._events.resize() // here's my workaround; manually calling resize to check if new content makes modal overflow page
})

But I think setContent() should trigger the resize event automatically.

MicahBrown added a commit to MicahBrown/tingle that referenced this issue Mar 26, 2018
@robinparisi
Copy link
Owner

robinparisi commented Mar 27, 2018

Hi @MicahBrown,

There is a public method specially made for this case:

var modal = new tingle.modal();
modal.open(); // modal content doesn't yet overflow the page at this point since it's blank

$.get('/ajax_content_url', function(response){
  modal.setContent(response);
  modal.checkOverflow();
})

In most cases, users set content first then open the modal. The checkOverflow() method needs an opened modal to work properly so I made this check in open() method. In other cases, you need to call checkOverflow() yourself.

@MicahBrown
Copy link
Contributor Author

MicahBrown commented Mar 27, 2018 via email

@robinparisi
Copy link
Owner

In this case, it would be great to check if the modal is open before calling the checkOverflow method in setContent.

@MicahBrown
Copy link
Contributor Author

@robinparisi I updated my PR.

@robinparisi
Copy link
Owner

@MicahBrown Thanks, I've just merged your PR. It will be available in the next release.

@MicahBrown
Copy link
Contributor Author

MicahBrown commented Mar 27, 2018 via email

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

No branches or pull requests

2 participants