Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy do I recieve both "$jQval is undefined" and "$.validator.unobtrusive is undefined" when using RequireJS?
    primarykey
    data
    text
    <p>This has had me puzzled for a few hours now. When the script is in a non-requirejs javascript file it works fine. When I use it with RequireJS it fails to work and gives me the error messages in the question title (though the firebug console).</p> <p>I was just trying to get it to "work" with RequireJS before attempting to refactor into a module. </p> <p>The Html is rendering correctly. The scripts are loading correctly. Also, I'm using the require-jquery.js bundle download, which is referenced in the layout template across all pages.</p> <p><strong>main.js</strong>: </p> <pre><code>require.config({ paths: { "maximum-filesize": "modules/validation/maximum-filesize" } }); require(["maximum-filesize", "domReady!"], function (maxFileSize) { }); </code></pre> <p><strong>maximum-filesize.js</strong></p> <pre><code>require.config({ paths: { "jquery-validate": "libs/jquery/jquery.validate", "jquery-validate-unobtrusive": "libs/jquery/jquery.validate.unobtrusive" } }); define(["jquery", "jquery-validate", "jquery-validate-unobtrusive", "domReady!"], function ($) { $.validator.unobtrusive.adapters.add( 'filesize', ['maxsize'], function(options) { options.rules['filesize'] = options.params; if (options.messages) { options.messages['filesize'] = options.message; } }); $.validator.addMethod('filesize', function (value, element, params) { if (element.files.length &lt; 1) { // No files selected return true; } if (!element.files || !element.files[0].size) { // This browser doesn't support the HTML5 API return true; } return element.files[0].size &lt; params.maxsize; }, ''); }); </code></pre> <p><strong>Edit 1</strong></p> <p>I just tried commenting out all of the above code, and replaced it with a simple:</p> <pre><code> $('#Name').val("Hello"); </code></pre> <p>This rendered "Hello" correctly in the #Name textbox, so JQuery is working.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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