1

I made a map application using Mapbox, where a user can click on a feature and a popup shows with details about the feature. I would also like to provide a link in the popup to the DetailView of the object using Javascript, but I'm having trouble generating the anchor tag. So far I have

new mapboxgl.Popup()
  .setLngLat(e.lngLat)
  .setHTML('<a href="{% url app_name:view pk=foo %}">To Detail View</a>')
  .addTo(map);

But when I try it out on the development server, it gives me a 404 error with a request url of http://127.0.0.1:8000/map/%7B%25%20url%20app_name:view%20pk%3Dfoo%20%25%7D

How do I get it to pass the correct url? I've also tried inserting the link into a normal HTML div and I get the same problem.

1 Answer 1

1

It looks like its not recognizing your template tag as a template tag. Your syntax looks fine. Are you trying to use the url template tag in a javascript file? If so it wont work. You can only use template tags in the html files.

If this is in a html file, can you post the full code?

Sign up to request clarification or add additional context in comments.

1 Comment

Yes it was in a javascript file. Moving it to the html file worked! Thanks very much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.