我正在使用 cocoon,并且我想在选择日期选择器中的日期(可以是多个日期)时自动添加子记录。
我可以像这样在coffeescript 中捕获日期选择,但我不知道如何通过cocoon 添加子记录,即通过模拟触发link_to_add_association 时发生的情况。
$(".form_multidate").datepicker().on 'changeDate', (e) -> alert(e.dates)
茧设置是一个标准的嵌套形式,没有技巧,在页面上工作正常。
编辑:评论重新绑定日历中提到的代码:
$(document).ready(function() {
$('#other_request_details')
.bind('cocoon:after-insert', function() {
return $('.datepicker-single').datepicker({
dateFormat: "DD, dd M yy"
});
});
});