I'm new to Backbonejs so maybe my problem is trivial. I want to generate a pdf with jsPDF in my backbonejs app. I'm using requirejs for scriptloading.
What I did:
I included the jsPDF script via bower and set the path in my main.js:
[...], paths: { [...], jspdf: '../bower_components/jspdf/jspdf' } }); [...]
This worked afaik since no error was thrown.
I included jsPDF in my view where I want to use it:
define([ 'jquery', 'jqueryui', 'underscore', 'backbone', 'templates', 'base64', 'jspdf' ], function ($, ui, _, Backbone, JST, Base64, jsPDF ) { 'use strict'; [...] }
I tried to create a new jsPDF with:
generatePdf: function() { var doc = new jsPDF(); }
And here I got the console output 'Uncaught TypeError: undefined is not a function'. What did I do wrong?
Thanks for any help!
Tim
EDIT:
Ok think I solved the problem. Since jsPDF seems to be not AMD-capable, I added
jspdf: {
exports: 'jsPDF'
}
to the shim config and then it worked properly.