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

lity.iframe is not a function (when running via npm/Laravel mix) #271

Open
adam-jones-net opened this issue Mar 8, 2021 · 0 comments
Open

Comments

@adam-jones-net
Copy link

adam-jones-net commented Mar 8, 2021

I think this is likely something very simple and it's just a syntax / setup type issue that I am unaware of having moved a working lity install under the Laravel Mix/WebPack system, which has caused it to stop working.

I'm using the following in my app.js of a laravel project to include lity:

window.lity = require('lity');

I then setup lity handlers follows just below this in the main js file:

$(document).ready(function() {
    lity.handlers('', function(target, instance) {
        // for specific page urls I add a class to the lity container
        if ( target.indexOf('/page1')>-1 || target.indexOf('/page-name2')>-1 ) {
            instance.element().find('.lity-container').addClass("lity-resize450");
        }
        return lity.iframe(target, instance);
    });
});

However I get errors once it's compiled such as:

app.js?20200217:62 Uncaught TypeError: lity.iframe is not a function
    at app.js?20200217:62
    at Function.<anonymous> (app.js?20200217:13561)
    at Function.each (app.js?20200217:2612)
    at factory (app.js?20200217:13548)
    at new Lity (app.js?20200217:13661)
    at lity (app.js?20200217:13724)
    at HTMLSpanElement.<anonymous> (app.js?20200217:461)
    at HTMLDocument.dispatch (jquery.min.js:2)
    at HTMLDocument.v.handle (jquery.min.js:2)

Anyone can please advise ? This worked when I was running lity without using Laravel Mix and had a manually assembled js file in my project.

I assume it's something to do with where/how I reference the lity object I've defined and that now needs altering since moving to Mix?

@adam-jones-net adam-jones-net changed the title Adding lity via laravel mix/webpack won't work when I define handlers lity.iframe is not a function (when running via npm/Laravel mix) Mar 12, 2021
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

1 participant