public static bool AsyncSubmit(jQueryObject form, Func <bool> validateBeforeSave, Action submitHandler)
        {
            var validator = form.As <jQueryValidationObject>().Validate();

            dynamic valSettings = validator.As <dynamic>().settings;

            if (valSettings.abortHandler != null)
            {
                return(false);
            }

            if (validateBeforeSave != null &&
                validateBeforeSave() == false)
            {
                return(false);
            }

            valSettings["abortHandler"]  = new Action <jQueryValidator>(Q.Externals.ValidatorAbortHandler);
            valSettings["submitHandler"] = new Func <bool>(delegate()
            {
                if (submitHandler != null)
                {
                    submitHandler();
                }
                return(false);
            });

            form.Trigger("submit");
            return(true);
        }
Exemple #2
0
        public static bool AsyncSubmit(jQueryObject form, Func<bool> validateBeforeSave, Action submitHandler)
        {
            var validator = form.As<jQueryValidationObject>().Validate();

            dynamic valSettings = validator.As<dynamic>().settings;
            if (valSettings.abortHandler != null)
                return false;

            if (validateBeforeSave != null &&
                validateBeforeSave() == false)
                return false;

            valSettings["abortHandler"] = new Action<jQueryValidator>(Q.Externals.ValidatorAbortHandler);
            valSettings["submitHandler"] = new Func<bool>(delegate()
            {
                if (submitHandler != null)
                    submitHandler();
                return false;
            });

            form.Trigger("submit");
            return true;
        }