1

I'm having some troubles while dragging an event with an url assiociated.

If you try to do that, you'll see that the event correctly moves, but also the click event is fired, so you'll visit the linked url (and that's bad).

I tried playing around with the eventClick callback, but with no luck.
Here you can find my code:

// calendar setup
eventDragStart : function(event, jsEvent, ui, view){
    event.dragging = true;
},
eventDragStop : function(event, jsEvent, ui, view){
    event.dragging = false;
},
eventClick : function(event, jsEvent, view){
    //even if I try to return always false, the link is still active
    if(event.dragging === true) return false;
},

Then i tried to manipulate the event link:

eventRender : function(event, element, view){
    $('a').click(function(){
    // custom function that checks if the event is being dragged or not
    //return dragCheck(event);
    return false;
    });
},

but still no luck. I think that while dragging, a new element is created, so every custom value is wiped out...

Any ideas?

4

1 回答 1

2

- 医生,当我打我的肚子时,我感觉很糟糕
- 所以,不要打它!

我在前面的座右铭之后找到了一个解决方案。
我没有使用原始url属性,而是创建了另一个custom_url.
这将阻止 fullcalendar 创建a元素,因此问题消失了。

在这里你可以找到我的代码。

用于获取事件的服务器端代码:

foreach($this->items as $row)
{
    $event = array();
    $event['id']         = $row->id_calendars;
    $event['title']      = $row->cal_title;
    $event['start']      = $row->cal_start;
    $event['end']        = $row->cal_end;
    $event['allDay']     = (bool) $row->cal_all_day;
    $event['custom_url'] = $row->url;

    $events[] = $event;
}

echo json_encode($events);

然后是javascript部分:

eventDragStart : function(event, jsEvent, ui, view){
      event.dragging = true;
},
eventDragStop : function(event, jsEvent, ui, view){
      event.dragging = false;
},
eventClick : function(event, jsEvent, view){
      if(event.dragging === true) return false;

      if(event.custom_url){
            window.location = event.custom_url;
      }
},

你完成了!

于 2012-10-12T12:51:46.990 回答