atlMapper
atlMapper

Reputation: 764

dojo amd load jquery undefined is not a function

I'm being forced to use the dojo amd loader and I'm folding in another portion of the project that was written the majority jquery selectors. I'm making a module to load in my jquery code but the first line is breaking.

question: how do I load jquery into a dojo module?

I've been searching around but can't seem to find this, I'm guessing its something simple...

define(['../../scripts/libs/jquery.js'], function($){
    "use strict";
$('#layers').click(function() {
    if ($('#layerMenu:visible').length > 0) {
        $('#layersMenu, #layersList').toggle();
        $('#basemapMenu, #bookmarkMenu').hide();
        $(this).toggleClass('navHighlight');
        $('#basemap, #bookmarks').removeClass('navHighlight');
    }
});
});

Upvotes: 2

Views: 1574

Answers (1)

dori naji
dori naji

Reputation: 980

You need to have a look at this link what you need is to configure your dojo loader to load files from not only dojo location but other location.

Solution:

1) you put the jquery library inside dojo files which is not a good idea

2) as i mention before to tell dojo configuration to look for files in another place.

var dojoConfig = {
    baseUrl: "/js/",
    tlmSiblingOfDojo: false,
    packages: [
        { name: "dojo", location: "lib/dojo" },
        { name: "dijit", location: "lib/dijit" },
        { name: "dojox", location: "lib/dojox" },
        { name: "my", location: "my", main: "app" },
        { name: "Jquery",location:"../../scripts/libs/"}
    ]
};

I would recommend to use full qualified path.

Upvotes: 5

Related Questions