如何在点击事件上填写文本字段?

时间:2014-10-22 11:52:19

标签: jquery ruby-on-rails fullcalendar

我正在使用jQuery Full Calendar并试图填写clickEvent上的文字字段 随着活动的时间。

time是我Event模型中属性的名称。

$(document).ready(function() {

    $('#calendar').fullCalendar({
                  eventClick: function() {

                            // set value?
                        $('#time').val("<%= @event.time %>");


                        }
    })

});

HTML来源:

<article class="blog-post margin-60">
<div id="calendar" class="fc fc-ltr">
<table class="fc-header" style="width:100%">
<tbody>
<tr>
<td class="fc-header-left">
<span class="fc-header-title"><h2>Oct 20 — 24 2014</h2></span>
</td>
<td class="fc-header-center"></td>
<td class="fc-header-right">
<span class="fc-button fc-button-today fc-state-default fc-corner-left fc-corner-right fc-state-disabled" unselectable="on">today</span>
<span class="fc-header-space"></span>
<span class="fc-button fc-button-prev fc-state-default fc-corner-left" unselectable="on"><span class="fc-text-arrow">‹</span></span><span class="fc-button fc-button-next fc-state-default fc-corner-right" unselectable="on">
<span class="fc-text-arrow">›</span></span></td></tr></tbody></table><div class="fc-content" style="position: relative;"><div class="fc-view fc-view-basicWeek fc-grid" style="position:relative" unselectable="on">
<div class="fc-event-container" style="position:absolute;z-index:8;top:0;left:0">
<div class="fc-event fc-event-hori fc-event-start fc-event-end" style="position: absolute; left: 3px; width: 147px; top: 24px;">
<div class="fc-event-inner"><span class="fc-event-title">08:00:00</span></div>
</div>
<div class="fc-event fc-event-hori fc-event-start fc-event-end" style="position: absolute; left: 3px; width: 147px; top: 47px;">
...

我错过了什么?

1 个答案:

答案 0 :(得分:0)

eventClick: function(event) {
    $('#time').val(event.start);
}

请参阅eventClickEvent_Object以供参考。基本上你使用你传入的javascript事件对象。你需要做一些处理来获得时间,但这不应该太困难。