Hide an icon if value is null

I have to hide an icon if a value of data detail is null.
It seems simple but… it doesn’t work. What am I doing wrong?

<a href="#" class="btn" dmx-bind:href="data_detail1.data.facebook" target="_blank"><i class="bi-facebook" dmx-show="data_detail1.data.facebook =! null"></i></a>

You don’t actually need the != null bit. Just putting the value location there will return false if it’s null. Also, you have =! Rather than !=

You could also move the DMX-show to the a tag so it is all hidden (although it is effectively hidden anyway with no content)

Sorry, maybe I didn’t make myself clear. I have a field in the database with a value corresponding to the link of a Facebook page. It can be null or not.
I would like the Facebook icon (which once clicked will go to the link) to appear only if the field is different from null

Well exactly as @bpj explains.

<a href="#" class="btn" dmx-bind:href="data_detail1.data.facebook" target="_blank"><i class="bi-facebook" dmx-show="data_detail1.data.facebook"></i></a>
1 Like