I want to add content to an ui-grid. It is some json data and sometimes there is no data available. Because of this I need the if clause:
if (typeof results.xyz[0] !== "undefined") {
$("#testing").append('<div class="ui-block-a" id="springboard2"><div class="springboardIcon"><a onclick="changeActorInfo('+results.xyz[0].id+')" href="#"><img src="http://www..."><span id="springboardLabelActors">'+results.xyz[0].name+'</span></a></div></div>');
} else {}
2 Problems:
1) Every time I load the data the content is added. But the previously added content should disappear.
2) The else{} clause is currently empty. When there is no json data available no content should be added.
How do I manage this? Thank you in advance!!