Console-msg: “Parsley's pubsub module is depre

2019-09-08 15:28发布

问题:

Trying to display error-msgs in a Bootstrap-Popup, I found a solution from TheDude and have adjusted the event-names for ps2.1:

$.listen('field:error', function (fieldInstance) {

    arrErrorMsg = ParsleyUI.getErrorsMessages(fieldInstance);
    errorMsg = arrErrorMsg.join(';');

    fieldInstance.$element
        .popover('destroy')
        .popover({
            container: 'body',
            placement: 'right',
            content: errorMsg
        })
        .popover('show');

});

$.listen('field:success', function (fieldInstance) {
    fieldInstance.$element.popover('destroy');
});

This works wonderfully, but I'm getting a msg in the JS-Console: "Parsley's pubsub module is deprecated; use the corresponding jQuery event method instead". There are very few hits for that msg in Google, and I'm afraid I'm not (yet) sufficiently versed with Parsley to understand and fix this problem - would appreciate some help to make my code future-proof :-)

回答1:

Sorry, I just was too impatient and started looking and it was easier than expected: the $.listen needs to be changed into window.Parsley.on. That's it! :-)