KJW
KJW

Reputation: 15251

Meteor: third party jquery library doesn't play nice with Meteor jquery package, how to force it to stop loading jquery.js?

I am trying to display an <img> inside the bootstrap modal view. Now, I am including a 3rd party jquery library which automatically manipulates all <img> tags with a specific class name.

html

{{afterBody}} this loads the js script at end of body. <#myModal> the modal dialog is hidden.

if (Meteor.isClient) {

        if ( typeof Handlebars !== 'undefined') {
            Handlebars.registerHelper('afterBody', function(name, options) {
                $('body').append('<script src="zzz.js" type="text/javascript"></script>');

            });
        }
    Meteor.startup(function() {
        $('#myModal').on('shown', function() { 
            alert('shown event fired');
            $('.modal-body').append('<imgsrc="http://www.y.com/images/example.jpg" class="markIt">');

    });
}

The problem is that zzz.js doesn't seem to play nice with the jquery.js package provided by meteor. I removed jquery package but it's still using the jquery.js from somewhere. I do not have anything in my public folder.

Uncaught TypeError: Object undefined [undefined undefined -1] has no method 'on'

This only happens when I include zzz.js anywhere. I tried the head, loading it after the body, but it just doesn't seem to want to work with the jquery meteor package. How do I replace the version of jquery to the one that worked with zzz.js? I'm certain that this is the problem.

Upvotes: 1

Views: 719

Answers (1)

datacarl
datacarl

Reputation: 2771

As far as I know, all you need to do in order to add a jQuery plugin is add the jquery smart package and then put the plugin (zzz.js) in your client directory (if you want it running on the client only). It will be available to you without any need to append the script tag.

Upvotes: 2

Related Questions