Coder Social home page Coder Social logo

Comments (10)

craigyu avatar craigyu commented on September 4, 2024 1

Thank you for the help!

from vue-scrollactive.

craigyu avatar craigyu commented on September 4, 2024 1

I've replaced all the spaces with dashes, still the same error.
The link below is the screenshot of my html code.
If you look at the div with href sides-&-sa, the is-active class is injected into that div, instead of <a>
https://puu.sh/x50fe/7b69c094af.png
I assumed that inner div is causing the trouble so i took it out, now it's working fine!

from vue-scrollactive.

eddiemf avatar eddiemf commented on September 4, 2024 1

Ohhh, now that makes sense, this inner div was not expected, I just released a quick fix for that, update the plugin and it should work with no more problems regarding that :)

But keep in mind not to use the IDs with space as that will cause unexpected behavior not from the plugin, but the selector won't find it.

Hope everything works now!

from vue-scrollactive.

craigyu avatar craigyu commented on September 4, 2024 1

Great, I'll keep that in mind, thank you!

from vue-scrollactive.

eddiemf avatar eddiemf commented on September 4, 2024

Can you please provide a fiddle with the error? I'll give it a better look later in the night to see if it's an actual bug with the plugin :)

from vue-scrollactive.

craigyu avatar craigyu commented on September 4, 2024

Sorry I don't think I'm able provide a js fiddle that reflects my current setting. I'm using scroll active inside a vue component that isn't root.
I got my some data from an http GET request, then processed the data inside created(){}.
Do you think the problem might be caused by the v-for?

from vue-scrollactive.

eddiemf avatar eddiemf commented on September 4, 2024

Yes, that might be the problem, I'll try to debug this later based on your settings, but as far as I've tested, it should work with dynamic items, but I didn't try with v-for. I'll perform some tests and let you know if I find something, thanks for the response :)

from vue-scrollactive.

eddiemf avatar eddiemf commented on September 4, 2024

Ok, I've managed to reproduce your error. It fires the error message but works correctly after that, I think the problem you have is because you're using code inside href, which is not compiled by Vue as it is just an HTML attribute, you should use :href instead, so this '#' + aCat.substr(0, 10) will be compiled by Vue as actual code, not a String. The way you're doing, you'll get the Cannot read property 'substr' of undefined because the result of that will be a '#' + aCat.substr(0, 10) string.

I'll patch it soon to remove the error when there aren't elements inside the component yet (as in your case when it's rendered by AJAX), but I think you might be just fine doing as I said.

Let me know if it works :)

from vue-scrollactive.

craigyu avatar craigyu commented on September 4, 2024

Thank you and sorry for the typo, I did use :href and it didn't work.
I reinstalled vue-scrollactive by uninstalling it first. The same problem persists.
The error is triggered by this line still:
var targetDistanceFromTop = this.getOffsetTop(document.getElementById(event.target.hash.substr(1)));

I have some spaces in the ID string, will that cause any problem? it jumps fine under href without vue-scrollactive

from vue-scrollactive.

eddiemf avatar eddiemf commented on September 4, 2024

Oh, that's probably what's going on here, you must not have any spaces in an ID using HTML. Try running document.getElementById(your ID with spaces) and see if it's returning anything. It's jumping to the section without the plugin probably because the browser is fixing it automatically.

Let me know if it works :)

Sent from my Motorola Moto G (4) using FastHub

from vue-scrollactive.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.