From a3afad36a60c2ef6146abd002b6c5348f648a9cc Mon Sep 17 00:00:00 2001 From: manson Date: Wed, 25 Jun 2014 11:33:19 +0800 Subject: [PATCH] Fix announcement preview for IE --- app/assets/javascripts/lib/modal-preview.js | 27 ++++++++++++--------- app/views/shared/preview/preview.html.erb | 10 +------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/lib/modal-preview.js b/app/assets/javascripts/lib/modal-preview.js index 5a684fd..8fe3e21 100644 --- a/app/assets/javascripts/lib/modal-preview.js +++ b/app/assets/javascripts/lib/modal-preview.js @@ -2,19 +2,24 @@ $(function() { $(".post_preview").click(function(){ $("#main-wrap").after(""); - var preview_url = $(this).attr('url'); + var preview_url = $(this).attr('url'); - $("form.previewable").ajaxSubmit({ - beforeSubmit: function(a,f,o){ - o.dataType = 'script'; - o.url = preview_url; - o.type = 'post'; - },success: function(msg) { + for ( instance in CKEDITOR.instances ) + CKEDITOR.instances[instance].updateElement(); + + var formData = new FormData( $('form.previewable')[0] ); + + $.ajax({ + type: "post", + url: preview_url, + data : formData, + processData: false, + contentType: false + }).done(function(data){ + $('#show_preview').html(data); $('#show_preview .modal').modal() - $('#show_preview .modal').height(function() { - return $(window).height() * 0.7; - }); - }}); + $('#show_preview .modal').height(($(window).height() * 0.7)); + }); }); $(".preview_trigger").click(function(){ $("#main-wrap").after(""); diff --git a/app/views/shared/preview/preview.html.erb b/app/views/shared/preview/preview.html.erb index dd67d2a..d2cb4bd 100644 --- a/app/views/shared/preview/preview.html.erb +++ b/app/views/shared/preview/preview.html.erb @@ -1,9 +1 @@ -<% if !request.xhr? %> - -<% end %> \ No newline at end of file +<%= render :partial=>"/shared/preview/modal_preview" %> \ No newline at end of file