aspnet/jquery-validation-unobtrusive

I don't want to initialize on page load

martijnbroekman opened this issue · 1 comments

Our webapplication uses jquery-validation with localization, but we have a problem. Our translations of the errors are loaded into the "data" attributes after the document ready event, so unobtrusive validation doesn't initialize with the right error messages.

Is it possible to disable the default initialization and replace it with our own event?

This is what i've done in our own project:

I've changed this

(function (factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define("jquery.validate.unobtrusive", ['jquery-validation'], factory);
    } else if (typeof module === 'object' && module.exports) {
        // CommonJS-like environments that support module.exports     
        module.exports = factory(require('jquery-validation'));
    } else {
        // Browser global
        jQuery.validator.unobtrusive = factory(jQuery);
    }
}(function ($) {

to this

// other file in our translation load event:
initializeUnobtrusiveValidation()

// jquery.validate.unobtrusive.js
function initializeUnobtrusiveValidation() {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define("jquery.validate.unobtrusive", ['jquery-validation'], factory);
    } else if (typeof module === 'object' && module.exports) {
        // CommonJS-like environments that support module.exports     
        module.exports = factory(require('jquery-validation'));
    } else {
        // Browser global
        jQuery.validator.unobtrusive = factory(jQuery);
    }
}

function factory ($) {

Hi. Thanks for contacting us.
We're closing this issue as there was not much community interest in this ask for quite a while now.
You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.