javascript - 如何访问 Fullcalendar 中的 JSON 字段?
问题描述
我正在用 PHP/jQuery 开发一个约会工具。我将所有约会作为 JSON 对象获取,如下所示:
[
{
"title": "Appointment with Zach Green{3}",
"appointment_id": "3",
"start": "2019-01-30T10:30:00",
"end": "2019-01-30T11:45:00",
"backgroundColor": "#226fbe",
"borderColor": "#226fbe"
},
{
"title": "Appointment with Mark Sammons{4}",
"appointment_id": "4",
"start": "2019-01-29T11:30:00",
"end": "2019-01-29T12:45:00",
"backgroundColor": "#226fbe",
"borderColor": "#226fbe"
}
]
目前,我appointment_id
通过附加到标题并在 jQuery 中解析 id 来传递。但是,appointment_id
它显示在我想避免的日历上。
附上日历截图
知道怎么做吗?
解决方案
您可以设置自定义属性并从事件中获取它,而不是传递标题。
例如:
<input type="hidden" data-id="yourid here" class="appoimentId">
$('.appoimentId').click(function(){
//id on each item click
console.log($(this).attr('data-id'));
})
推荐阅读
- json - JQ:将变量属性添加到现有对象
- typescript - 用于查询嵌套对象的带有点符号的打字稿类型安全字符串
- angular - 为什么 import { EMPTY } from 'rxjs' 不起作用?
- html - 用 Scrapy 抓取时排除某个标签
- c# - 如何在c#中设置模板
- c# - 我正在寻找一种方法来监视键盘上特定键的状态并将一系列按键发送到特定程序
- javascript - 为什么添加不可见的非交互式覆盖会提高滚动同步的性能?[铬合金]
- oracle - Oracle Apex 创建一个拆分为多个区域的表单
- android - 如何向 FragmentContainerView 添加可访问性委托?
- java - Spring Webflux / Reactor:reactor-http-nio vs boundedElastic