ruby-on-rails - 到特定 div 的动作电缆
问题描述
我正在寻找可以根据 stream.id 更改的特定 div。
我有以下内容:
ActionCable.server.broadcast('webconferencier_channel', participants_html: participants_html, stream_id: webconferencier.stream_id)
我在哪里通过stream_id
.
我希望像这样在咖啡文件中检索它:
received: (data) ->
# Called when there's incoming data on the websocket for this channel
participantsHtml = data.participants_html
$('#show_participants' + data.stream_id).html(participantsHtml);
然后将视图更新为:
<div id="show_participants_#{<%= @stream.id %>}">
</div>
我可以看到 AC 发送带有其他变量的 div 模板,但我似乎无法检索和更新它。我认为我的咖啡语法不正确。
在视图中,div id 显示为:
<div id="show_participants_#{67089dbd-9826-41f2-97bc-b774b667ef66}">
</div>
UUID 与我通过咖啡文件传递的字符串完全相同。有谁知道我该怎么做?谢谢
解决方案
id
您应该从 div 的like中删除花括号和 octothorp show_participants_UUID
。
您可以将 console.log 添加到咖啡中,以查看里面发生了什么。
推荐阅读
- javascript - 有没有办法在上传反应原生之前检查图像大小?
- flutter - 如何在颤动的 back4app 用户对象上设置额外的必填字段
- javascript - Req.file 是未定义的nodejs multer
- c# - ASP.NET Core 5 API 属性中的通用日志记录
- java - 获取数组中的联系人列表
- javascript - WordPress 类别、子类别、活动类别问题
- java - 我们可以为了方法级别的单元测试而将方法的访问说明符从私有更改为默认吗
- ios - 如何使用 Snap-kit 插入圆形微调器
- javascript - 如何在 Node/Express 应用程序中检测浏览器或选项卡关闭?
- oracle-jet - 我们如何从 OJet (Oracle JavaScript Extension Toolkit) 7.x 升级到 10.0?我们在哪里可以找到 10.0 版的 oraclejet.zip?