Browse Source
Merge pull request #1057 from abpframework/maliming/blogvalidate
fix #1051 new/edit post jquery validate problem.
pull/1060/head
Yunus Emre Kalkan
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
28 additions and
5 deletions
-
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/BloggingPage.cs
-
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/edit.js
-
modules/blogging/src/Volo.Blogging.Web/Pages/Blog/Posts/new.js
|
|
|
@ -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); |
|
|
|
|
|
|
|
|
|
|
|
@ -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); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
@ -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); |
|
|
|
}); |
|
|
|
|