1

这是默认的disqus代码:

<div id="disqus_thread"></div>
    <script type="text/javascript">
        /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
        var disqus_shortname = 'mysite'; // required: replace example with your forum shortname

        /* * * DON'T EDIT BELOW THIS LINE * * */

...

我想根据显示页面的对象的 id 添加一个 disqus_identifier。我尝试了以下两种解决方案,但没有成功。

var disqus_identifier = "<%=mysite_#{@illustration.id}%>"; 

var disqus_identifier = "mysite_<%=#{@illustration.id}%>"; 

您如何将 ruby​​ 值插入到 js 变量中?

4

1 回答 1

2

您与第二个示例非常接近。您需要像这样构造它:

var disqus_identifier = "mysite_<%= @illustration.id %>";
于 2013-09-29T18:49:19.460 回答