1

Actually, I have something like this :

$(document).ready(function()
{
...JQUERY CODE HERE...
}

But i would like, to only change the way i included my script library and use Require.JS. This is what i have done so far :

    <script type="text/javascript">
        requirejs.config({
            paths: {
                jquery: 'js-jQuery/jquery.js',
                jqueryui: 'js-jQuery/jquery-ui.custom.min.js'
            },            
            shim: {
                'jqueryui': {
                deps: ['jquery'],
                exports: '$'
                }
            }
        });

        requirejs([
            'jquery',
            'jqueryui'
        ]);
</script>

I always get an error on my "$(document).ready". Do I really need to change my "Current" way of using "document.ready" to use a plugin like "domReady"?

4

1 回答 1

2

不,您只需要确保在使用之前已包含 jQuery。

require(["jquery","jqueryui"],function($){
    $(document).ready(...

});
于 2013-01-18T16:55:51.387 回答