Closed cap10morgan closed 7 years ago
It would seem to me that you could just build that filtering logic into your nav-handler
function.
We ended up putting it into path-exists?
as a thing it checks for first and returns false
if it sees this path, and that works b/c it does make accountant stay hands off for the nav part but still lets it load the content when the popup requests it. But it feels very wrong and brittle because this path does exist, we just don't want accountant to do its normal link handling on it. If we wanted to use this path anywhere else without a popup, for example, it would force a full page load.
Would you entertain a PR to make this a little cleaner?
Sure. What sort of approach did you have in mind? Some sort of id or class blacklist?
Good question. I think there are a few options, and am curious which you prefer (or maybe you even know of another one I didn't think of):
data-accountant="ignore"
on the <a>
element and leave those links to default behavior when present.<a>
element and do the same as #1 when present (I don't love this one).target
attrs set and leave them to default behavior.I think my preference would be to implement both #1 and #3. Seems like it should always leave links with target
attrs alone, and #1 gives people the ability to turn off accountant for individual links for whatever other reasons they might have.
My preference would be not to force any change on the template side (i.e. no data-accountant
tags).
It sounds like the specific case you're worried about is one in which a link should ordinarily open a new tab or window, in which case I agree, Accountant should get out of your way and filtering on the target attr makes sense (though ideally we'd leave _self
alone).
There is a pull request that explicitely ignores empty/non-existing href attributes to allow accountant to know the difference between navigational links and links that are only used to trigger javascript actions.
@smee your pull request solves a different use case than the one that @cap10morgan is trying to solve, I believe.
When will this appear in the clojars?
When I merge #35, as noted in the PR.
It's up on Clojars now at 0.1.8
Is there a way to have a link which accountant would normally preventDefault and handle instead do the default behavior? Our use case is wanting to open some content that is rendered by our SPA in a popup. accountant seems to prevent that from working.
It would be nice if we could tell accountant somehow "don't handle this one" in the
<a>
element itself, or if accountant detected links w/ thetarget
attr set and didn't handle them.