$(document).ready(function(){ var filecount = 0; function updatePreview(data, type) { $("#preview-contents").html(data); } function reloadPreview() { var src = $('#src').val(); var title = $('#title').val() $("#preview-contents").contents().find("html").load("/preview", $("#edit-form").serializeArray()); } function appendFileForm() { filecount += 1; var newForm = $("
"); newForm.insertAfter(".uploader:last"); newForm.find(':file').change(function() { $(this).upload("@{AttachR (YablogDay day) ident}", $(this).parent().serialize(), function(html){}); }); } $('#show-preview').click(function(){ reloadPreview(); }); $('#append-file').click(function() { appendFileForm(); }); $(':file').change(function() { $(this).upload("@{AttachR (YablogDay day) ident}", $(this).parent().serialize(), function(html){}); }); });