0

I'm trying to include a custom js-library/script in my RequireJS-config but it doesnt seem to work. So I hope someone can help me out. I'm using RequireJS in combination with Backbone and Handlebars, so just to mention it...

In my Require config I have:

require.config({

paths: {

    jquery: 'lib/jquery/jquery',
    backbone: 'lib/backbone/backbone',

    // Templating.
    handlebars: 'lib/handlebars/handlebars',

    // Plugins.
    jqueryEffects: 'lib/jquery/jquery.effects',
    ... //some more libraries

},

shim: {
    backbone: {
        deps: ['jquery', 'lodash','jqueryEffects'],
        exports: 'Backbone'
    },
    lodash: {
        exports: '_'
    },
    handlebars: {
        exports: 'Handlebars'
    },
    jqueryEffects : {
        deps: ['jquery']
    }
  }
});

The jquery.effects.js is a simple script i created my own to handle special click events or run animations etc. When i start to run my backbone app, the console tells me that the script is loaded. So now on one of my Views, I have rendered a HTML file which contains an anchor with a class which serves as an identifier, which after clicking it should trigger something...BUT, nothing happens, so I tried to make an alert in the jquery.effects.js-file:

$(function() {
 alert($(".videoname").lenght);
});

This gave me the response undefined. Does anyone maybe have an idea? The same goes when I add more libraries, console says they are loaded, but nothing happens... ?!?!?!??

1 Answer 1

1

try this (length not lenght) :

(function() {
    alert($(".videoname").length);
})();

That's means that your script is working ;)

Sign up to request clarification or add additional context in comments.

3 Comments

Ha you were right! I misspelled... Now I get the value 0, and after I clean the cache, it says $ not defined (that is a general problem of mine)
Can you add the jquery.effects.js full code to your question ?
Or you can use it as a require.js module : define(['jquery'], function($) { alert($(".videoname").length); });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.