Help adding new library into Meteor app (Javascript) card.js


#1

Hi, I am trying to add thi library so that users can input credit card information (https://github.com/jessepollak/card) but I just can’t make it work, I tried already to import the jQuery jquery.card.js in many different ways, but I always get the error that undefined is not a function when I try to run

$('form').card({
    // a selector or DOM element for the container
    // where you want the card to appear
    container: '.card-wrapper', // *required*

    // all of the other options from above
});

Can somebody please explain to me the best way to add this library to my Meteor app? Thanks!


#2

First, check if this library in on Atmosphere.js and if it is then you can add it as meteor add name:package

if not then you can do the following which I do with my projects:

  1. Place the jquery.card.js in /client/compatibility or client/lib folder. You can then add your code

    in Template.body.onCreated or in ‘Template.body.onRendered’

Hope this helps.


#3

Thanks you so much, I was looking all the weekend for a way to make this work, and Template.body.onRendered made it work perfectly!


#4

If jquery.card.js is a properly maintained jQuery plugin that others might want to use, you might consider publishing it as a Meteor package.

I put together a boilerplate / starter-kit to help make packaging jQuery plugins clear, easy and simple. I’d love to get feedback on it to improve it :

fliptext package and fliptext-demo