Skip to content
Snippets Groups Projects
Commit d4801222 authored by alexisben's avatar alexisben
Browse files

add tiny js helper to validate form on click on html node parent

parent eaf68aab
No related branches found
No related tags found
No related merge requests found
/* global $ */
window.osuny.validateFromClickManager = {
init: function () {
'use strict';
this.elements = document.querySelectorAll('.js-validate-form-click');
if (this.elements.length > 0) {
this.listen();
}
},
listen: function() {
'use strict';
this.elements.forEach(function(element) {
this.bindClick(element)
}.bind(this));
},
bindClick: function(element) {
'use strict';
var form = element.querySelector('form');
if (!form) {
return;
}
element.style.cursor = "pointer"
element.addEventListener('click', function() {
form.submit();
});
},
invoke: function () {
'use strict';
return {
init: this.init.bind(this)
};
}
}.invoke();
window.addEventListener('DOMContentLoaded', function () {
'use strict';
window.osuny.validateFromClickManager.init();
});
......@@ -14,7 +14,7 @@
%>
<% next unless template.allowed_for_about? %>
<div class="col-xxl-2 col-lg-3 col-md-4 d-flex">
<div class="<%= 'card' if current_admin_theme == 'appstack' %> flex-fill position-relative">
<div class="<%= 'card' if current_admin_theme == 'appstack' %> flex-fill position-relative js-validate-form-click">
<%= image_tag "communication/blocks/templates/#{kind}.jpg", alt: '', class:"card-img-top block__image" %>
<div class="<%= 'card-body' if current_admin_theme == 'appstack' %>">
<h3 class="h4 block__title"><%= t "enums.communication.block.template_kind.#{kind}" %></h4>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment