Skip to content

Commit 600057f

Browse files
authored
Demos: Make autocomplete demos work on jqueryui.com
The `jqueryui.com` demos build process deAMDifies HTML files, replacing required JS files with direct script tags. On the other hand, when running demos locally from the jQuery UI repository, RequireJS is used. This used to work fine until we got a new `search.js` file introduced in jquerygh-2187. The deAMDifying process doesn't touch non-HTML files which made loading autocomplete demos crash on "require is not a function" To resolve the issues without a major rearchitecture of the build process, the `search.js` file now detects AMD and uses `require`, falling back to relying on the `jQuery` global in the other case. Closes jquerygh-2274 Ref jquerygh-2187 Ref jquery/jqueryui.com#216
1 parent 5665215 commit 600057f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

demos/search.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
require( [ "jquery", ], function( $ ) {
1+
( function( factory ) {
22
"use strict";
3+
4+
if ( typeof define === "function" && define.amd ) {
5+
6+
// Fetch jQuery as an AMD dependency
7+
require( [ "jquery" ], factory );
8+
} else {
9+
10+
// Use the jQuery browser global
11+
factory( jQuery );
12+
}
13+
} )( function( $ ) {
14+
"use strict";
15+
316
var database = {
417
"Great Bittern" : "Botaurus stellaris",
518
"Little Grebe" : "Tachybaptus ruficollis",

0 commit comments

Comments
 (0)