DMXzone App Connect Support Product Page

Answered

How do I show/hide elements depending on multiple factors?

Asked 28 Mar 2018 08:33:12
1
has this question
28 Mar 2018 08:33:12 Bruce Wilkie posted:
How do I show or hide an item depending on the result of two different factors, such as field values in a single select/query?

eg:
Show the div if either query.field1 OR query.field2 has a value

Note, in my case I've got a table of racing fixtures and for each row in the table I want to link to a results page for but only if a results pdf or a report pdf is available for that particular racing fixture.

My code so far for the repeating row is below, but it's not working at the moment:

<tr dmx-repeat:repeatfixtures="seriesfixtureconnection.data.SeriesFixtureList">
<td>{{fixtureround}}</td>
<td>{{fixturedate1}}
<span dmx-show="fixturedate2"> - {{fixturedate2}}</span></td>
<td>{{venue}}</td>
<td><a href="" title="Dowload Entry form for Round {{fixtureround}}" dmx-show="entryform" dmx-bind:href="./datafiles/fixturefiles/{{entryform}}">download now</a><span dmx-hide="entryform">not available</span></td>

<!-- the table cell below - I'm trying to show if either of two query fields has a result -->

<td><a href="" title="view results/reports for Round {{fixtureround}}" dmx-show="reportfile OR resultfile" dmx-bind:href="series_fixture_results.php?fixtureid={{fixtureid}}&seriesid={{seriesid}}">view results/reports</a><span dmx-hide="reportfile OR resultfile" >not available yet</span></td>

</tr>


thanks in advance

Bruce

Replies

Replied 03 Apr 2018 08:35:01
03 Apr 2018 08:35:01 Bruce Wilkie replied:
Could somebody get in touch with me about this?

I'm behind in my project schedule. I really need to know how to do this for my client.

thanks
Bruce
Replied 03 Apr 2018 09:06:33
03 Apr 2018 09:06:33 George Petrov replied:
Hi Bruce,

You can enter as condition any javascript expression (or use the data formatter to generate one)
So logical operators are && for AND and || for OR

In your case you can write: query.field1 || query.field2

dmx-show="reportfile || resultfile"

or compare with some value:
dmx-show="reportfile == 'somevalue' || resultfile == 'other'"
Replied 03 Apr 2018 14:30:55
03 Apr 2018 14:30:55 Bruce Wilkie replied:
Thanks George

I've got the data formatter but it doesn't say anywhere how to generate the javascript for this. Can you link me to a guide for it?

In the mean time I've just edited the source code so, replacing 'OR' with '||' to read dmx-show="reportfile || resultfile" and that's got it working on the page, thanks for that


Replied 11 Apr 2018 10:42:30
11 Apr 2018 10:42:30 Bruce Wilkie replied:
Hi again

Did you get my earlier question about data formatter?
How do I use it to generate the javascript to do this again?

Bruce

Reply to this topic