Form Widget

- added public js code to handle validation and ajax submit
- added widget initializer
- added form widget
- added acceptance test for adding the widget
This commit is contained in:
Jonathan Labreuille
2015-08-20 16:52:51 +02:00
parent eda2188611
commit c883de9aa8
5 changed files with 243 additions and 8 deletions

View File

@ -1,8 +1,22 @@
define('public', ['jquery'], function(jQuery) {
jQuery(function($) {
// dom ready
$(function() {
define('public', ['jquery', 'jquery-validation'],
function($) {
function isSameDomain(url) {
var link = document.createElement('a');
link.href = url;
return (window.location.hostname === link.hostname);
}
$(function() {
// setup form validation
$('form.mailpoet_form').validate({
submitHandler: function(form) {
console.log(form);
$(form).ajaxSubmit({
target: "#result"
});
}
});
});
});
});
}
);