diff --git a/app/views/libraries/_form.html.erb b/app/views/libraries/_form.html.erb
index f2fcc68a..6d4af4b3 100644
--- a/app/views/libraries/_form.html.erb
+++ b/app/views/libraries/_form.html.erb
@@ -43,7 +43,7 @@
<%= link_to '确认提交', 'javascript:void(0)', class: 'white-btn edu-blueback-btn changebtn mr20 fl apply-publish-btn' %>
- <%= f.submit('保存', class: 'white-btn edu-blueline-btn changebtn mr20 fl') %>
+ <%= link_to '保存', 'javascript:void(0)', class: 'white-btn edu-blueline-btn changebtn mr20 fl submit-btn' %>
<% end %>
@@ -80,10 +80,32 @@
});
$(function(){
+ var submitForm = function(){
+ var title = $("input[name='library[title]']").val();
+ var content = $("textarea[name='library[content]']").val();
+
+ if (!title || title.length == 0) {
+ alert('请输入标题');
+ return
+ }
+ if (!content || content.length == 0) {
+ alert('请输入描述');
+ return
+ }
+
+ if($('.attachments_fields .attachment').length == 0){
+ alert('请上传附件');
+ return
+ }
+
+ $('.library-form-container form').submit();
+ };
+
$('.apply-publish-btn').on('click', function(){
$('input[name="apply_publish"]').val(true);
- $('.library-form-container form').submit();
+ submitForm();
});
+ $('.submit-btn').on('click', submitForm);
var message = '<%= flash[:message] %>';
if (message.length > 0) {