diff --git a/app/views/wiki/_editor.html.haml b/app/views/wiki/_editor.html.haml
index aeacc039f..29b666abc 100644
--- a/app/views/wiki/_editor.html.haml
+++ b/app/views/wiki/_editor.html.haml
@@ -36,7 +36,8 @@
%br
= submit_tag t("layout.wiki.save_button"), :id => "gollum-editor-submit", :title => t("layout.wiki.save_changes")
- = link_to t("layout.wiki.preview"), "javascript:void(0)", :id => "gollum-editor-preview", :class => "minibutton", :title => t("layout.wiki.preview_title")
+ = link_to t("layout.wiki.preview"), "javascript:void(0)", :id => "gollum-editor-preview",
+ :class => "minibutton", :title => t("layout.wiki.preview_title"), :'data-url' => preview_project_wiki_index_path(@project)
- content_for :javascripts do
= javascript_include_tag 'gollum/editor/gollum.editor.js'
diff --git a/public/javascripts/gollum/editor/gollum.editor.js b/public/javascripts/gollum/editor/gollum.editor.js
index 296c1ed3e..075887eab 100755
--- a/public/javascripts/gollum/editor/gollum.editor.js
+++ b/public/javascripts/gollum/editor/gollum.editor.js
@@ -63,11 +63,18 @@
// get form fields
var oldAction = $('#gollum-editor form').attr('action');
var $form = $($('#gollum-editor form').get(0));
- $form.attr('action', $form.attr('action') + '/preview');
+ $form.attr('action', $('#gollum-editor #gollum-editor-preview').attr('data-url'));
$form.attr('target', '_blank');
+ //$form.find('input[name=_method]').val('post');
+ var $oldMeth = $('#gollum-editor form input[name=_method]');
+ if ( $oldMeth.length ) {
+ $oldMeth.remove();
+ }
$form.submit();
-
+ if ( $oldMeth.length ) {
+ $form.append($oldMeth);
+ }
$form.attr('action', oldAction);
$form.removeAttr('target');
return false;