我在rails应用程序中使用fullcalender。 我有以下的CoffeeScript代码:ruby on rails coffeescript输入表格
select: (start, end, allDay) ->
title = prompt("Event Title:", "")
hours = prompt("Hours", "")
if title
...
代替使用2个提示代码行,我想有一个与两个数据字段小弹出窗口。我应该如何实现它?我应该使用Bootstrap模式吗?
感谢
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>`
但是,对于标题和小时值不在我的CoffeeScript代码的其余部分可用:
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
模态对话框可以工作,是的。 –