noob: ajax form events not firing?

Following https://yii2-cookbook.readthedocs.org/forms-activeform-js/




$(document).ready(function () {

    fm=$('#psigate-form');


    fm.on('beforeSubmit', function (event, jqXHR, settings) {

        debugger;

        console.log('b4submit');

        return true;

    });


    fm.on('beforeSend', function (e) {

        debugger;

        console.log('b4send');

        return true;

    });

    fm.on('ajaxComplete', function (e) {

        debugger;

        console.log('ajaxComplete')

        return true;

    });

    fm.on('ajaxBeforeSend', function (e) {

        debugger;

        console.log('ajaxBeforeSend');

        return true;

    });

});



The only event that fires is beforeSubmit, and it does not get the jqXHR and settings args.

I have somehow failed to "connect" my form with the logic in /vendor/yiisoft/yii2/assets/yii.activeForm.js

Coming from extJS background, pedalling madly now to figure out how the rest of the world was doing stuff with jQuery

Ultimately I want to mask a payment form after submit is clicked to prevent double posting.

I think I have exhausted google today, and still I am missing bits of the puzzle.

Any example of a form using events, where can I see how they are wired up?

I got my asset publishing figured out, that was something. I’m guessing there’s something I need to do in the view …

FAILURES:

Stuff I found on the web that came close but I failed to connect dots.


/**

                AjaxSubmitButton::begin([

                    'label' => 'Check',

                    'ajaxOptions' => [

                        'type' => 'POST',

                        'url' => 'country/getinfo',

                        / *'cache' => false,* /

                        'success' => new \yii\web\JsExpression('function(html){

                            $("#output").html(html);

                        }'),

                    ],

                    'options' => ['class' => 'customclass', 'type' => 'submit'],

                ]);

                AjaxSubmitButton::end();

**/


                // todo blur on submit http://stackoverflow.com/questions/28102106/yii2-submit-and-validate-a-form-by-using-a-button-outside-the-form

                ?>

<!--

                <div class="form-group">

                    < ?= Html::submitButton('Submit', [

                        'class' => 'btn btn-primary',

                        'name' => 'psigate-button',

                        //'onclick' =>  "BH.submitForm($(this).parents('form').attr('id'));"

                        'options' => ["onclick=BH.submitForm($(this).parents('form').attr('id'));"]

                    ]) ?>

                </div>





                    <button type="submit" class="btn btn-primary" name="psigate-button" onclick="BH.submitForm($(this).parents('form').attr('id'),this);">Submit</button>                </div>


-->

                <div class="form-group">

                    <button type="submit" class="btn btn-primary" name="psigate-button" >Submit</button>                </div>

                </form>

            </div>

                <?php ActiveForm::end(); ?>




Thank you kindl for any hints…