Allow conditional 'navigo-data' attribute for the '<a href="">' element
See original GitHub issueHello,
Firstly, thank you for the great library! The new version (v8) looks very good so far.
Currently, I am facing an issue where sometimes I want to pass a full url e.g. https://github.com/
to the href=''
tag without Navigo’s support. Other times I want to pass a local path e.g. path/somewhere
and enable Navigo’s functionality by adding navigo-data
attribute.
I am using Navigo in conjuntion with Alpine.js and thought I would be able to do something like this <a href="https://github.com/" navigo-data="!this.isUrl">
where isUrl = true
.
Maybe there is a way to do this that I don’t know about, please advise.
P.S. I know I could probably achieve this conditionally, either with navigate()
function or conditioning the element (<a href='https://'>
vs. <a href='/' navigo-data>
), but wondering if this could this be a feature?
Thank you ✌️
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
Well,
updatePageLinks
doesn’t remove the listeners that are already attached to links. So, there is some work required to achieve what you want. It’s on my list already.There is a new version
8.5.0
which:"false"
as value ofdata-navigo
attribute. In this case it skips the link and the link works as a normal onetarget="_blank"
Also have in mind that if some link is instrumented, or in other words wired to Navigo logic you can change its
data-navigo
value to"false"
and callrouter.updatePageLinks()
. This will remove the click listener and will make the link work as a normal link.Let me know if it doesn’t work as expected and I’ll reopen the issue.