杰森(Json)事件不起作用,并且工作日不正确 [英] Json event does not work, and the weekday is not right

查看:145
本文介绍了杰森(Json)事件不起作用,并且工作日不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的日历上有一些有事件的日期.应使用从JSON调用中接收到的数据突出显示事件的日期.当我单击事件日期时,应显示事件.问题是我的JSON数据未获取,并且事件未显示.另外,工作日也不对.

On my calendar there are dates that have events. The dates with the events should be highlighted with data received from a JSON call. When I click on an event date the event should be shown. The problem is my JSON data is not being fetched and the events don't show. Also, the weekday isn't right.

发出JSON请求的我的showInfo代码如下. Codepen 显示了完整的代码示例.

My showInfo code that makes the JSON request is below. The Codepen shows the full code example.

 // show info
function showInfo(event) {
  // link 
  var url = 'https://codepen.io/nakome/pen/EWBMzm.css';
  // get json
  getjson(url, function(obj) {
    for (var key in obj) {
      // if has envent add class
      if(_('[data-id="' + key + '"]')){
        _('[data-id="' + key + '"]').classList.add('event');
      }
      if (event === key) {
        _('#calendar_data').classList.toggle('show_data');
        // template info
        var data = '<a href="#" class="hideEvent" '+
            'onclick="return hideEvent();">&times;</a>'+
            '<h3>' + obj[key].type + '</h3>' +
            '<dl>' +
            '<dt><dfn>Title:</dfn></dt><dd>' + obj[key].title + '</dd>' +
            '<dt><dfn>Hour:</dfn></dt><dd>' + obj[key].time + '</dd>' +
            '<dt><dfn>Venue:</dfn></dt><dd>' + obj[key].venue + '</dd>' +
            '<dt><dfn>Location:</dfn></dt><dd>' + obj[key].location + '</dd>' +
            '<dt><dfn>Description:</dfn></dt><dd>' + obj[key].desc + '</dd>' +
            '<dt><dfn>More Info:</dfn></dt><dd><a href="' + obj[key].more +
            '" title="More info">Here</a></dd>' +
            '</dl>';

        return _('#calendar_data').innerHTML = data;
      }
    }
  });
  return false;
}
// toggle event show or hide
function hideEvent(){
    _('#calendar_data').classList.toggle('show_data');
}

推荐答案

我认为问题在于,您的showInfo()在calendar()函数开始时已被注释掉.删除评论,这样:

I think the problem is that your showInfo() was commented out at the start of the calendar() function. Remove the comment so this:

// showInfo();

成为这个:

showInfo();

我已经将 Codepen 更新了.com/questions/44332814/calendar-start-weeks-at-monday>原始问题在这里,这样您就可以看到事件正在出现.我不确定工作日不对"是什么意思.

I have updated the Codepen for the original question here so you can see that the events are showing up. I'm not sure what you meant by the 'weekday is not right'.

这篇关于杰森(Json)事件不起作用,并且工作日不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆