i'm having trouble figuring out when to load my jquery (from a separate js file into the durandal view).
i want to do things like attach event handlers like i would normally do using jquery's $(document).ready(function(){});
in shell.js i'm trying to load my other js file called unicorn.js by using requirejs like so:
define(function(require) {
var router = require('durandal/plugins/router');
var unicorn = require('../../content/js/unicorn');
return {
router: router,
activate: function () {
return router.activate('dashboard');
},
viewAttached: function () {
console.log('viewattached');
unicorn.setup();
}
};
});
it seems to load ok, but tells me that in my unicorn.js file, 'define is not defined'. here's what that looks like:
define(function () {
var unicorn = {
setup: function() {
$('a').click(function(e) {
//do stuff
});
};
});
what am i doing wrong?