title: loading jquery validation using requirejs
body: <p>I am struggling with <a href="http://requirejs.org/" rel="nofollow">requirejs</a>. I have following jquery validation custom addon module defined:</p>
  
  <p><strong>validation-addon.js</strong></p>
  
  <pre><code>define(['jquery', 'jquery.validate', 'jquery.validate.unobtrusive'], 
  
  function ($) {
  
      $.validator.setDefaults({
          highlight: function (element) {
              $(element).closest('.form-group').addClass('has-error');
          },
          unhighlight: function (element) {
              $(element).closest('.form-group').removeClass('has-error');
          }
      });
  
      ....
  });
  </code></pre>
  
  <p>My requirejs config file :</p>
  
  <p><strong>config.js</strong></p>
  
  <pre><code>require.config({
      baseUrl: '/Scripts',
      paths: {
          'jquery': 'lib/jquery-2.0.3',
          'jquery.validate': 'lib/jquery.validate',
          'jquery.validate.unobtrusive': 'lib/jquery.validate.unobtrusive',
      },
      shim: {
          'jquery.validate': {
              deps: ['jquery']
          },
          'jquery.validate.unobtrusive': {
              deps: ['jquery.validate']
          }
      }
  });
  </code></pre>
  
  <p>I am using these modules on my mvc user regitration view like this:</p>
  
  <p><strong>register.cshtml</strong></p>
  
  <pre><code>require(['/Scripts/modules/config.js'], function () {
      require(['modules/user-register', 'modules/validation-addon'], 
  
       function (userregistration) {
          //using user registration module here..
      }
  
    );
  });
  </code></pre>
  
  <p>The problem i am facing is little weird. When i go to user registration view <strong>first time</strong> and input wrong values in use input fields than custom <em>highlight and unhighlight</em> functions which i have overridden on jquery validator is not executing but if i reload the register view itself than it suddenly start executing.</p>
  
  <p>My feeling is that may be this is happening because of the loading sequence of modules, but i dont understand how to solve this, can anybody please help me to solve this issue ?</p>