Parsley JS changes
authorAlex Kellner <alexander.kellner@in2code.de>
Sun, 18 May 2014 12:46:09 +0000 (14:46 +0200)
committerAlex Kellner <alexander.kellner@in2code.de>
Sun, 18 May 2014 12:46:09 +0000 (14:46 +0200)
Resources/Public/Js/PowermailCond.js

index 2a6f3d4..fcce9b9 100644 (file)
@@ -95,12 +95,6 @@ function checkConditions(uid) {
                                        showAll(); // show all fields and fieldsets at the beginning
                                }
                        }
-
-                       // TODO Detach Parsley
-                       // Form validation
-                       if ($.fn.validationEngine) {
-                               $('.powermail_form').validationEngine('detach');
-                       }
                },
                error: function() {
                        $('form.powermail_form').append('Error in PowermailCond.js in checkCondtions function by opening the given url');
@@ -229,6 +223,12 @@ function deRequiredField(uid, disableAjaxRequest) {
                element.removeProp('data-parsley-required'); // remove parsley-required attribute
                element.data('powermailcond-required', 'required'); // add own data required attribute
        }
+       if (isParsleyValidationActivated()) {
+               // reinit parsley seems only to work with required="required" and not with data-parslay attributes :(
+               var form = $('form.powermail_form_'+ getFormUid());
+               form.parsley().destroy(); // turn off parsley
+               form.parsley(); // turn on parsley again
+       }
 }
 
 /**