vendredi 1 mai 2020

Hide button for modal if empty

I'm currently working on a web interface for Excel reports relating to stock in a warehouse using Flask. I've built a table using DataTables that pulls data from a csv file and it's working away. I've been asked to add in an extra data cell at the end of each row which has a clickable button to open notes if a note exists on the csv file for that stock item. I'm trying to use a Font Awesome icon for the user to click to open a modal which shows the note however I cannot get the icon to only appear when there is a note to view.

Here's what I've tried

<tbody>                     
    

                            
</tbody>

And here is the jQuery I've tried -

$("#notes").find('hide_show').filter(function() {
return !this.firstChild; 
}).hide();

I have based my attempt off this answer --> Hide div's if they are empty

The other issue I have is that when the modal opens, it shows the same note (the note for stock item number 1) for each stock item regardless.

How do I get the icon to only appear when there is a note and then get the correct note to appear in the modal when opened?

Any help would be greatly appreciated! Thanks

Aucun commentaire:

Enregistrer un commentaire