Note that there are some explanatory texts on larger screens.

plurals
  1. POhead js + jquery.validate.unobtrusive + custom validators
    text
    copied!<p>I'm using <code>head.js</code> (http://headjs.com) to do async loading of my javascripts. </p> <p>I have problem with <code>jquery.validate.unobtrusive</code> and custom validators</p> <p>All custom validations should be loaded after <code>jquery.validate</code> and <code>jquery.validate.unobtrusive</code>, and I do it like following:</p> <pre><code>&lt;head&gt; &lt;script src="@Url.Script("jquery")"&gt;&lt;/script&gt; &lt;script src="@Url.Script("head.load")"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- entire markup --&gt; &lt;script&gt; head.js("@Url.Script("jquery.validate")", function () { head.js("@Url.Script("jquery.validate.unobtrusive")", function () { head.js("@Url.Script("custom-validations")"); }); }); &lt;/script&gt; &lt;/body&gt; </code></pre> <p>The problem is that <code>custom-validations</code> script should be loaded after <code>jquery.validate.unobtrusive</code> but before <code>document.onready</code> event, because <code>jquery.validate.unobtrusive</code> uses <code>document.onready</code> to do it's black magic. But, when I'm using <code>head.js</code> <code>document.onready</code> event fired before scripts starts to load, and my custom validation does not work.</p> <p>Is there any common solutions/workarounds to solve this kind of problems with async script loading?</p> <p>Another problem that my customer does not want to see <code>jquery.validate</code>/<code>jquery.validate.onubtrusive</code> in <code>&lt;head&gt;</code> tag.</p> <hr> <p><code>@Url.Script</code> - helper method for locating js files.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload