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

$case is not defined #12

Closed
jelewis8 opened this issue Apr 13, 2015 · 6 comments
Closed

$case is not defined #12

jelewis8 opened this issue Apr 13, 2015 · 6 comments

Comments

@jelewis8
Copy link

When clicking a lightcase link, I get "Uncaught ReferenceError: $case is not defined"

jQuery is present, and all other jQuery functions and plugins work. I've tried isolating just lightcase, with same result.

I'll try duplicating on another site, but this one has me stumped.

UPDATE: I've isolated the page so it's just got jquery 1.10.2 and lightcase. Same issue.
My function call looks like this:
$('a[data-rel^=lightcase]').lightcase();

@cbopp-art
Copy link
Owner

Did you ensure that you call lightcase only after the whole DOM is loaded? Sounds like you have included all javascript sources within the head tag but the function call not beeing executed when document is ready and $('body') is undefined yet.
If so, just do the function call like this:

jQuery(document).ready(function ($) {
        $('a[data-rel^=lightcase]).lightcase();
});

or alternatively:

(function ($) {
    $(function ()  {
        $('a[data-rel^=lightcase]).lightcase();
    });
})(jQuery);

@jelewis8
Copy link
Author

I've called lightcase within the document ready function, I've also called it with (window).load, so it definitely is getting loaded after dom is loaded. And, like I said, all my other jquery functions work within that same document ready block. I've also isolated it so just lightcase is loading, and nothing.

This is the weirdest thing, b/c I have used lightcase on literally dozens of other projects without any issues.

I even tried going back to previous versions, but I get the same problem.

I'm using jquery 1.10.2.

@jelewis8
Copy link
Author

I figured it out. This is bizarre.

My lightcase stylesheet had an id on it, like this:
<link rel="stylesheet" id="lightcase-css" href="css/lightcase.css" type="text/css" media="all" />

Removing the id="lightcase-css" makes it work. Keeping the id on there causes the "$case is not defined" error.

What would cause this?

UPDATE: changing the id to something different does not cause the same problem. So, that specific ID is causing problems.

@cbopp-art
Copy link
Owner

I figured out that this line is producing the error.

This wildcard selector seems to be a bit too generic, obviously. It checks if the neccessary markup is already added or not and will not do the call lightcase.settings.markup(); e.g. in your case.
I will have a look at this and implement an alternative solution which would allow to add id attributes to the markup starting with the lightcase.settings.idPrefix.

Thanks for your feedback about this issue and let's keep the status open.

@jelewis8
Copy link
Author

Glad to have helped. I thought I was going crazy for a while.
Keep up the great work, this is a fantastic plugin.

@cbopp-art
Copy link
Owner

@jelewis8
Fixed and available with the new release v2.1.0

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

2 participants