Railsアプリでフルカレンダーを使用しています。私は次のコーヒースクリプトコードを持っています:
select: (start, end, allDay) ->
title = prompt("Event Title:", "")
hours = prompt("Hours", "")
if title
...
2つのプロンプトコード行を使用する代わりに、両方のデータフィールドを含む小さなポップアップウィンドウが必要です。どのようにそれを達成する必要がありますか?ブートストラップモーダルを使用する必要がありますか?
ありがとう
OK ---このモーダルを作成しましたが、正常に表示されます。
<div id="calModal" class="modal hide fade" tabindex="-1" role="dialog" aria- labelledby="myModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Create Labor</h3>
</div>
<div class="modal-body">
<form class="form-inline" method="get">
<input type="text" id="title" class="input" placeholder="Title" name="title">
<input type="floating" id="hours" class="input" placeholder="Hours" name="hours">
</form>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>`
しかし、titleとhoursの値は、私のコーヒースクリプトコードの残りの部分では使用できません。
select: (start, end, allDay) ->
$('#calModal').modal('show')
title = $(".modal-body #title").val
hours = $(".modal-body #hours").val
if title
$.create "/events/",
event:
title: title,
starts_at: "" + start,
ends_at: "" + end,
all_day: allDay,
workorder_id: 1,
# need a modal for inputing these fields
hours: hours,
employee_id: 1
# pickup the current employee
$('#calendar').fullCalendar('refetchEvents')`
これらのステートメントは機能していません:
title = $(".modal-body #title").val
hours = $(".modal-body #hours").val