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

Decouple show/hide mechanism from hash when JS available #17

Closed
Schepp opened this issue Apr 25, 2013 · 4 comments
Closed

Decouple show/hide mechanism from hash when JS available #17

Schepp opened this issue Apr 25, 2013 · 4 comments
Milestone

Comments

@Schepp
Copy link
Contributor

Schepp commented Apr 25, 2013

My suggestion would be to decouple visibility of the modal from the hash once JS is available - reason being that this leaves the page's author with the possibility of using the hash as a means of navigation through his site (be it hashbang based or not).

This would also open ways to stack multiple modals on top of each other.

@drublic
Copy link
Owner

drublic commented Jun 29, 2013

This would currently need a lot of rewrite of the whole JS functionality and also add more complexity that is not needed in a lot of cases.
It is possible to use hashes for navigation on a page since modal.js doesn't touch the the DOM or anything if it has evaluated that the hash doesn't belong to a modal.

There might be plugins out there that have problems with interacting with hash-changes that don't belong to their "area of acting" but this seems to be the problem of the respective plugin rather than CSS Modal. There might also be other plugins like accordions that rely on the hash being used.

One more advantage of using hashes is that it enables deeplinking to modals which can be extremely useful.

So as a conclusion I don't bother too much at the moment to move away from using the hash where appropriate.

Thanks anyway for raising this issue.

@drublic drublic closed this as completed Jun 29, 2013
@sebald
Copy link

sebald commented Dec 2, 2013

I ran into a similiar problem today, b/c Sizzle did throw some weird errors. I tracked the source down to CSS-Modal. I doesn't brake the site or anything. But the error messages are kinda unpleasant.

What about an additional "namespace" for the modal to solve conflicts like that.
Like: http:https://example.com/#modal=myModal and care only about hashchange events with the namespace.

The = maybe not a good idea here. But it is semantically clear.

@anselmh
Copy link
Contributor

anselmh commented Dec 2, 2013

@sebald Without knowing you exact problem I don't see a reason why this should result in an error. It's up to you how you name your modal's ID. If I misunderstood you, please can you elaborate on your issue?

@sebald
Copy link

sebald commented Dec 3, 2013

@anselmh I actually noticed that the version the project I am working on is older. Newser version of CSS-Modal do not use jQuery anymore, but I think it still could lead to problems with other JS.
Let me try again :)

CCS-Modal and the other plugin are working toghether without disrupting one another. But what make me uncomfortable is the fact that CSS-Modal is greedy when it comes to hash changes. Meaning, for whatever reason the hash changes CSS-Modal recognizes that change and tries to find and show a modal.

I find it problematic that it always tries to find/show a modal, because this could possibly lead to a conflict with other JavaScript if the CSS-Modal isn't robust enough and throws an error. I guess in 80% of the time there will be no issue, but it would be nice if you could pass the CSS-Modal an option so it "runs" in its own scope.

One solution to this woul be what @Schepp suggested. Another one would be to use a prefix in the hash so that CSS-Modal only runs when the hash contains the prefix.

drublic added a commit that referenced this issue Dec 16, 2014
This commit adds the possibility to call a modal without changing the
current hash. It is possible to do so by setting a data attribute
`data-modal-nohash` to the link which calls the modal.

Closes #99.
Reference #17.
drublic added a commit that referenced this issue Dec 16, 2014
This commit adds the possibility to call a modal without changing the
current hash. It is possible to do so by setting a data attribute
`data-modal-nohash` to the link which calls the modal.

Closes #99.
Reference #17.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants