fullcalendar事件单击vs事件内的链接

时间:2022-12-29 00:01:51

I have a question. Maybe this is not possible but I was hoping for clarification. Fullcalendar right now has it so if there is a url inside the event, the whole event is clickable and just takes you to that particular url. In my case I need to have a link inside the event that has to be clickable. See Fiddle

我有个问题。也许这是不可能的,但我希望澄清。 Fullcalendar现在拥有它,所以如果事件中有一个url,整个事件都是可点击的,只是带你到那个特定的url。在我的情况下,我需要在事件内部有一个必须可点击的链接。见小提琴

Please let me know if there is a way to disable the event click itself but only keep the click of the link available. I know that there is a way to disable an event like this:

如果有办法禁用事件点击本身但请保持点击链接可用,请告诉我。我知道有一种方法可以禁用这样的事件:

 eventClick: function(event) {
        return false;
}

However, this will disable everything even the link inside the event. Eventually all of the events will be pulled via ajax or some other way from DB to populate the calendar. So keep in mind that I will need to provide a URL in some way for the event to pick it up.

但是,即使是事件内的链接,这也会禁用所有内容。最终所有事件都将通过ajax或其他方式从DB中提取以填充日历。所以请记住,我需要以某种方式提供一个URL,以便事件来获取它。

1 个解决方案

#1


2  

Did you try the example from fullcalendar docs?

您是否尝试过fullcalendar文档中的示例?

$('#calendar').fullCalendar({
  events: [{
    title: 'My Event',
    start: '2017-01-13',
    url: 'http://google.com/'
  }],
  eventClick: function(event) {
    if (event.url) {
      //if you want to open url in the same tab
      location.href = "https://example.com";
      //if you want to open url in another window / tab, use the commented code below
      //window.open(event.url);
      return false;
    }
  }
});

I don't know how do you render the link in your events, but this should do what you need.

我不知道你如何在你的活动中呈现链接,但这应该做你需要的。

Best regards
Krzysztof

最好的问候Krzysztof

#1


2  

Did you try the example from fullcalendar docs?

您是否尝试过fullcalendar文档中的示例?

$('#calendar').fullCalendar({
  events: [{
    title: 'My Event',
    start: '2017-01-13',
    url: 'http://google.com/'
  }],
  eventClick: function(event) {
    if (event.url) {
      //if you want to open url in the same tab
      location.href = "https://example.com";
      //if you want to open url in another window / tab, use the commented code below
      //window.open(event.url);
      return false;
    }
  }
});

I don't know how do you render the link in your events, but this should do what you need.

我不知道你如何在你的活动中呈现链接,但这应该做你需要的。

Best regards
Krzysztof

最好的问候Krzysztof