0

So I have a some HTML where I am pulling a value from a file and using it for a link, like so:

<a href="{{ var('page').value }}">page</a>

Now I need a popup to display that page when clicked, using a basic script and a line like this:

<a href="page.html" onclick="return popitup('page.html')">page</a>

However, I need the popup page value to be pulled from the file as well, so something like this:

<a href="{{ var('page').value }}" onclick="return popitup('{{ var('page').value }}')">page</a>

But the problem I am having is that the variable does not resolve in the popitup() call, I assume because of the apostrophes basically telling it to take that literally. What could fix this and make it resolve?

This is in conjunction with AngularJS

6
  • 1
    What language is the {{}} representing/ Commented Oct 19, 2015 at 17:32
  • Could you create a fiddle illustrating the problem? Commented Oct 19, 2015 at 17:33
  • HTML alone is not supposed to know what to do with {{ }}. If you were using angular JS or another Javascript framework, then it could work. Commented Oct 19, 2015 at 17:33
  • It is using AngularJS Commented Oct 19, 2015 at 17:36
  • 2
    You should be using ngClick and incorporating your popup that way. Commented Oct 19, 2015 at 17:39

2 Answers 2

2

I'm going to assume that the first snippet you posted. If it works, great; this answer should work for you. If not, well, I don't know - more information would be needed, like a fiddle illustrating the problem or know what templating engine you're using.

Since the function "popitup" needs the save value as the href of the link, why not pass in the href of the link?

<a href="{{ var('page').value }}" onclick="return popitup(this.href)">page</a>
Sign up to request clarification or add additional context in comments.

1 Comment

It does work, and this works perfectly. Thank you! A big part of the problem I was having is I myself could not recall what templating engine we were using so Googling was tough.
0

ngClick is the way to deal with that kind of things if you are using Angular.

This was anserwed here, and if you really need the onclick attribute: how to pass angular js variable inside onclick function as parameter

Comments

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.