This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Pages: 1 - Last Post: 02-May-2017 00:38 Last Post By: jGromit
ctwist

Posts: 565
Registered: 27-Sep-2003
JavaScript condition error
Posted: 20-Apr-2017 16:06
 
  Click to reply to this thread Reply
I am trying to convert from BeanShell to JavaScript.

In a JavaScript htt file, a condition
<ja:if test="<%= (navigationTop || navigationBottom) %>">
always returns false.

My solution is to evaluate the condition in compiled Java, and pass a boolean variable to the htt file. This allows me to use
<ja:if test="${...}">
which evaluates correctly.

Is there an alternative solution?
jGromit

Posts: 7,545
Registered: 31-Jan-2006
Re: JavaScript condition error
Posted: 20-Apr-2017 17:23   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
In a JavaScript htt file, a condition
<ja:if test="<%= (navigationTop || navigationBottom) %>">
always returns false.

I can't imagine why that would be the case. I just did a little test with the JS version of Minimal, plugged this into index.htt, and it works properly every time:
<ja:if test="<%=showAlbumTitle || googleMaps%>">One of them is true</ja:if>
ctwist

Posts: 565
Registered: 27-Sep-2003
Re: JavaScript condition error
Posted: 02-May-2017 00:28   in response to: jGromit in response to: jGromit
 
  Click to reply to this thread Reply
Yes there is a problem in my code. I should have done some more testing before reporting this.
jGromit

Posts: 7,545
Registered: 31-Jan-2006
Re: JavaScript condition error
Posted: 02-May-2017 00:38   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
Yes there is a problem in my code. I should have done some more testing before reporting this.

Been there. Done that.
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums