How to use jQuery File Upload with RequireJS

Sebastian Tschan edited this page Sep 14, 2014 · 3 revisions

First, download and add require.js to the js directory.

Next, edit index.html and replace all the script sources starting with jQuery:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
...
<script src="js/main.js"></script>

Replace them with the following single script source:

<script data-main="js/main" src="js/require.js"></script>

Next, edit js/main.js and replace its content with the following:

require(
    [
        'http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js',
        'https://blueimp.github.io/JavaScript-Templates/js/tmpl.min.js',
        'https://blueimp.github.io/JavaScript-Load-Image/js/load-image.all.min.js',
        'https://blueimp.github.io/JavaScript-Canvas-to-Blob/js/canvas-to-blob.min.js',
        'js/jquery.iframe-transport',
        'js/jquery.fileupload-ui'
    ],
    function() {
        $('#fileupload').fileupload({
            url: 'server/php/'
        });
    }
);
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.