Browse Source

fix #1051 new/edit post jquery validate problem.

pull/1057/head
maliming 7 years ago
parent
commit
eab6493252
  1. 5
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/BloggingPage.cs
  2. 14
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/edit.js
  3. 14
      modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/new.js

5
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/BloggingPage.cs

@ -55,6 +55,11 @@ namespace Volo.Blogging.Pages.Blog
public IHtmlContent RenderMarkdownToHtml(string content)
{
if(content.IsNullOrWhiteSpace())
{
return new HtmlString("");
}
byte[] bytes = Encoding.Default.GetBytes(content);
var utf8Content = Encoding.UTF8.GetString(bytes);

14
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/edit.js

@ -1,4 +1,4 @@
(function ($) {
$(function () {
var $container = $("#edit-post-container");
var $editorContainer = $container.find(".edit-post-editor");
@ -72,6 +72,8 @@
load: function () {
$editorContainer.find(".loading-cover").remove();
$submitButton.prop("disabled", false);
$form.data("validator").settings.ignore = '.ignore';
$editorContainer.find(':input').addClass('ignore');
}
}
}).data(editorDataKey);
@ -82,8 +84,16 @@
var postText = newPostEditor.getMarkdown();
$postTextInput.val(postText);
if (!$form.valid()) {
var validationResult = $form.validate();
abp.message.warn(validationResult.errorList[0].message); //TODO: errors can be merged into lines. make sweetalert accept HTML.
e.preventDefault();
return false; //for old browsers
}
$submitButton.buttonBusy();
$(this).off('submit').submit();
});
})(jQuery);
});

14
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/new.js

@ -1,5 +1,4 @@
var editor = null;
(function ($) {
$(function () {
var $container = $("#qa-new-post-container");
var $editorContainer = $container.find(".new-post-editor");
@ -72,6 +71,8 @@
load: function () {
$editorContainer.find(".loading-cover").remove();
$submitButton.prop("disabled", false);
$form.data("validator").settings.ignore = '.ignore';
$editorContainer.find(':input').addClass('ignore');
}
}
}).data(editorDataKey);
@ -82,6 +83,13 @@
var postText = newPostEditor.getMarkdown();
$postTextInput.val(postText);
if (!$form.valid()) {
var validationResult = $form.validate();
abp.message.warn(validationResult.errorList[0].message); //TODO: errors can be merged into lines. make sweetalert accept HTML.
e.preventDefault();
return false; //for old browsers
}
$submitButton.buttonBusy();
$(this).off('submit').submit();
});
@ -113,4 +121,4 @@
}
});
})(jQuery);
});

Loading…
Cancel
Save