I am creating a table row with a "spinner" to show actions when a button is pressed.
I append the row id to the spinner's id to be able to target it specifically.
For example row 21: #spinnerAction-21
While iterating through the data set, I add the name to array, so I can hide all of them after the html is inserted into the page.
Though I can't get my spinners to hide.I tried using inline CSS visibility to hidden but I couldn't un-hide it when I was done.
Any help on hiding my spinners? Is there a better way to do this?
var spinnerArray = $.makeArray();
for (var i = 0; i < data.length; i++) {
html += '<tr>';
html += '<td>';
//other html output
html += '<i class="fa fa-spinner fa-spin" id="spinnerAction-' + data[i].entry_id + '" style="font-size:24px;color:dodgerblue;"></i>';
html += '</td>';//end button comlumn
html += '</tr>';//end row
//Add a reference to the spinner for that row to hide.
spinnerArray.push("#spinnerAction-" + data[i].entry_id);
}//end for
// insert the html rows
$('#display_info').append(html);
//hide the spinner in each row
$.each(spinnerArray, function (index, val) {
$(val).hide();
});
idattributes like this. It leads to needlessly complicated code which is difficult to read and maintain. Instead use common class names and select related elements by DOM traversal. I would give you a more concrete example of how to do this, but the structure of your page is unclear given the JS alone.valisn't the object it's the value of the spinner, it's not the element. You have to grab the spinner and use.hide()spinnerArrayis a list of element IDs (with a preceding #).