Block acknowledgement submit when no category is available
This commit is contained in:
1 parent
e19c710660
commit
9fdd153695
1 file changed
+12
-1
@@ -3,6 +3,17 @@
|
||||
<%= f.label :content, t('category'), class: 'control-label' %>
|
||||
<%= f.select :category_id, options_for_select(@categories) %>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
var $cat = $("select[name='<%= f.object_name %>[category_id]']");
|
||||
$cat.closest("form").off("submit.category_check").on("submit.category_check", function(){
|
||||
if(!$cat.val()){
|
||||
alert("<%= j((I18n.locale.to_s == 'zh_tw') ? '沒有可選擇的類別。每個類別只能設定一筆,若尚未建立類別或所有類別都已設定,請先到「類別」頁面新增類別,或直接編輯既有的設定。' : 'No category available. Each category can only have one setting. If no category exists or all categories are already set, please add a new category on the Categories page first, or edit an existing setting.') %>");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<% end %>
|
||||
<div class="control-group">
|
||||
<%= f.label :content, t('ask.acknowledgements'), class: 'control-label' %>
|
||||
@@ -13,4 +24,4 @@
|
||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||
<%= f.button t('cancel'), type: 'button', class: 'btn', onclick: 'history.back();' %>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user