jquery - 如何在 json 中的事件标题中添加换行符

标签 jquery fullcalendar

我无法弄清楚的一件事是能够添加 html 而不会被转义或实际创建新行

这是我的 json:

{ "id": 30,
  "title": "Basics \n  Awesome Abs & Butt Blast \n  Danielle B",
  "start": "2010-05-11T08:00:00-04:00",
  "end": "2010-05-11T08:30:00-04:00",
  "allDay": false
}

这是它的代码:

[
  <% @events.each do |e| %>
        { "id": <%= e.id -%>,
        "title": "<p><%= e.event_template.level %></p><p><%= e.monqi_class.title %></p><p><%= e.instructor.last_initial %></p>",
            "start": "<%= e.start_date.iso8601 %>",
            "end": "<%= e.end_date.iso8601 %>",
            "allDay": false
         }
        <%= @events.last == e ? "" : ","  %>
    <% end -%>
]

所以我试图在偶数 3 行中包含(级别、类(class)名称和讲师)

问题是它被转义了,所以字符没有被 html 解析

你能帮我吗?

非常感谢

阿米

最佳答案

使用标记进行换行,例如 ~| ,然后将其替换为 <br />在输出上。

关于jquery - 如何在 json 中的事件标题中添加换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2811796/

相关文章:

jquery - 使用 mysql 和 nodejs 更新查询时出现 ER_PARSE_ERROR

jquery - 滚动时将背景移出图片

javascript - 查找两个标签/节点之间的文本

javascript - 回调函数作为带参数的字符串

jquery - 覆盖滚动禁用

jquery - 如何更改 fullcalendar 中本周的背景颜色 http ://arshaw. com/fullcalendar/

fullcalendar - 全日历 ListView 中的自定义列

周 View 中的 FullCalendar 自动高度

javascript - fc-sun 的全日历背景图像

javascript - meteor js 和全日历