Two JavaScript-Bugs in Version 1.4
-
If you send the cleverreach form without filling the mail field. It’ll be send using Ajax. Now filling or not filling the field, the form is send without using Ajax.
Fixing this I noticed that on Ajax post the wrong element is replaced. You’re only replacing the form which’ll leave the error message.
var haet_cleverreach = haet_cleverreach || {}; jQuery(document).ready(function($) { $(document).on('submit', '.haet-cleverreach-form', function() { var $form = $(this); var submission = {}; $form.find('.cleverreach-loader').slideDown(400); $form.find('[name]').each(function(){ var $field = $(this); submission[$field.attr('name')] = $field.val(); }) var data = { 'action': 'cleverreach_submit', 'submission': submission }; $.post(ajax_object.ajax_url, data, function (response) { $form.closest('.haet-cleverreach').replaceWith(response); }); return false; }); });
As you see I’m using a live event handler which isn’t deleted on replacing the form. Besides I’m using closest to get the necessary parent element.
Greats from Germany
Jan
- The topic ‘Two JavaScript-Bugs in Version 1.4’ is closed to new replies.