[issue #64] Fixed bug with preview page.

This commit is contained in:
George Vinogradov 2012-01-18 04:41:36 +04:00
parent 407130f3d7
commit d3b32e4d6d
2 changed files with 11 additions and 3 deletions

View File

@ -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'

View File

@ -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;