如果播放列表为空,我有一个设置为隐藏的 SoundCloud 小部件。当有人将歌曲添加到播放列表(单击添加按钮)时,是否有重新检查条件的方法?
<% if @current_user.id == Integer(@party_profile.host) %>
<div <% if @firstsong == "undefined" %> style="display:none;" <% end %>>
<object height="81" width="80%" id="myPlayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
<iframe id="sc-widget" width="95%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https://api.soundcloud.com/tracks/<%= @firstsong %>&show_artwork=true&liking=ture&sharing=true&frameborder="no"&scrolling="no"&enable_api=true&object_id=myPlayer"></iframe>
</object>
</div>
<% end %>
我添加这个红宝石条件而不是在点击时刷新 soundcloud 小部件的一部分的原因是因为我不希望每次有人添加歌曲时都刷新小部件(仅当播放器被隐藏并添加了新歌曲时) .