Trip.js icon indicating copy to clipboard operation
Trip.js copied to clipboard

Requirejs failing on Tripjs

Open JohnRSim opened this issue 8 years ago • 3 comments

require([ 'pathTo/trip.js' ], function(Trip) { console.log(Trip); });

Trip is undefined in console.log - however Trip.js is loaded on page. Using requirejs 2.3.0 and tripjs 3.3.3

JohnRSim avatar Sep 05 '16 12:09 JohnRSim

@jdorfman plz check how i use it here in the official site of Trip.js - http://eragonj.github.io/Trip.js/js/demo.js

EragonJ avatar Sep 05 '16 15:09 EragonJ

Hi Eragon - I've been looking at that and playing and think something is wrong. You define and load tripjs outside of requirejs first and then load it in again as part of requirejs within the document.js

  • If you get a blank page and setup require and do something like this
$('#blah').on('click', function() {
    require([
        'http://eragonj.github.io/Trip.js/vendor/trip.js/trip.min.js'
    ], function(Trip) {
        // ...
        console.log(Trip);
    });
});

You will see Trip is undefined etc and error on constructor.

However if you load trip and define it - it works fine.

JohnRSim avatar Sep 05 '16 16:09 JohnRSim

@JohnRSim Trip.js is dependent on jQuery, did you also handle that path in your requirejs configuration ? https://github.com/EragonJ/Trip.js/blob/master/dist/trip.js#L19

EragonJ avatar Sep 08 '16 09:09 EragonJ