michaelmcgurk
michaelmcgurk

Reputation: 6509

Uncaught TypeError: undefined is not a function - GravityForms AJAX Spinner

Why is this giving me an Uncaught TypeError: undefined is not a function error:

<script>
    function gformInitSpinner_1() {
        jQuery('#gform_1').submit(function() {
            if (jQuery('#gform_ajax_spinner_1').length == 0) {
                jQuery('#gform_submit_button_1, #gform_wrapper_1 .gform_next_button, #gform_wrapper_1 .gform_image_button').after('<' + 'img id="gform_ajax_spinner_1"  class="gform_ajax_spinner" src="/content/plugins/gravityforms/images/spinner.gif" alt="" />');
            }
        });
    }
    jQuery(document).ready(function($) {
        gformInitSpinner_1();
        jQuery('#gform_ajax_frame_1').load(function() {
            var contents = jQuery(this).contents().find('*').html();
            var is_postback = contents.indexOf('GF_AJAX_POSTBACK') >= 0;
            if (!is_postback) {
                return;
            }
            var form_content = jQuery(this).contents().find('#gform_wrapper_1');
            var is_redirect = contents.indexOf('gformRedirect(){') >= 0;
            var is_form = !(form_content.length <= 0 || is_redirect);
            if (is_form) {
                jQuery('#gform_wrapper_1').html(form_content.html());
                jQuery(document).scrollTop(jQuery('#gform_wrapper_1').offset().top);
                if (window['gformInitDatepicker']) {
                    gformInitDatepicker();
                }
                if (window['gformInitPriceFields']) {
                    gformInitPriceFields();
                }
                var current_page = jQuery('#gform_source_page_number_1').val();
                gformInitSpinner_1();
                jQuery(document).trigger('gform_page_loaded', [1, current_page]);
                window['gf_submitting_1'] = false;
            } else if (!is_redirect) {
                var confirmation_content = jQuery(this).contents().find('#gforms_confirmation_message').html();
                if (!confirmation_content) {
                    confirmation_content = contents;
                }
                setTimeout(function() {
                    jQuery('#gform_wrapper_1').replaceWith('<' + 'div id=\'gforms_confirmation_message\' class=\'gform_confirmation_message_1\'' + '>' + confirmation_content + '<' + '/div' + '>');
                    jQuery(document).scrollTop(jQuery('#gforms_confirmation_message').offset().top);
                    jQuery(document).trigger('gform_confirmation_loaded', [1]);
                    window['gf_submitting_1'] = false;
                }, 50);
            } else {
                jQuery('#gform_1').append(contents);
                if (window['gformRedirect']) {
                    gformRedirect();
                }
            }
            jQuery(document).trigger('gform_post_render', [1, current_page]);
        });
    });
</script>

Thanks for any advice :-)

Upvotes: 0

Views: 1038

Answers (1)

aelgoa
aelgoa

Reputation: 1201

Somewhere, within the myriad patterns of these programming instruction statements, lies a variable, whose value assignment is absent in total from proper declaration, aloof to the compiler's awareness.

Upvotes: 2

Related Questions