2016-03-21 78 views
0

我正在嘗試在事件結束時顯示「x」,以便用戶單擊它時會從顯示中刪除該事件。完整日曆在事件標題顯示結尾附加'x'

我使用下面的代碼可以這樣做:

eventRender: function(event, element) { 
     element.append("<span class='closeon'>X</span>"); 
     element.find(".closeon").click(function() { 
      $('#calendar').fullCalendar('removeEvents',event._id); 
     }); 
    } 

然而, 'X' 上線下方出現,就像這樣:

Event ...

如何我可以做到這一點,所以它顯示在一行上的事件?

感謝您的幫助提前。

回答

1

使用prepend代替append

CSS

.closeon { float: right; } 

JS

eventRender: function(event, element) { 
    var e = element.prepend("<span class='closeon'>&#10005;</span>"); 

    e.children('.closeon') 
     .attr('data-event-id', event._id) 
     .click(function() { 
      var id = $(this).attr('data-event-id'); 
      $('#calendar').fullCalendar('removeEvents',id); 
     });    
} 

[http://jsfiddle.net/8fa0j9d8/]

相關問題