JavaScript Issue...

Liam W

in memoriam 1998-2020
I'm stumped on this, can someone here help me out?

I've created a javascript file and have registered something, as per the file below...

Code:
/**
* @param {jQuery} $
*            jQuery Object
*/
!function($, window, document, _undefined) {

    XenForo.VPPCodes = {
        ShowCode : function($form) {
            console.log($form);

            $form.bind('AutoValidationComplete', function(e) {

            });
        }
    };

    XenForo.register('form.VPPForm', XenForo.VPPCodes.ShowCode);

}(jQuery, this, document);

However, the $form variable just contains 0 and as such an error is thrown when I try to bind an event handler to it (or whatever it's called).

Any ideas?
 
Most XenForo JS takes this format:

Code:
/** @param {jQuery} $ jQuery Object */
!function($, window, document, _undefined)
{
    XenForo.VPPCodesShowCode = function($form)
    {
        console.log($form);
    };

    XenForo.register('form.VPPForm', 'XenForo.VPPCodesShowCode');
}
(jQuery, this, document);

For me, it works fine:

[form.VPPForm, context: form.VPPForm, jquery: "1.11.0", constructor: function, selector: "", toArray:function…]
 
Most XenForo JS takes this format:

Code:
/** @param {jQuery} $ jQuery Object */
!function($, window, document, _undefined)
{
    XenForo.VPPCodesShowCode = function($form)
    {
        console.log($form);
    };

    XenForo.register('form.VPPForm', 'XenForo.VPPCodesShowCode');
}
(jQuery, this, document);

For me, it works fine:

I changed it to that after making this post and it had the same issue.

I'll try again after I've had some lunch... And a drink.
 
Top Bottom