javascript - How can I use JointJS with Meteor? -


i trying run sample app jointjs tutorial, i've got far.

1) sampleapp.html

   <head>   <title>sampleapp</title>  </head>  <body>   <h1>welcome meteor!</h1>    {{> hello}} </body>  <template name="hello">   <div></div> </template> 

2) sampleapp.js

if (meteor.isclient) {    template.hello.onrendered(function () {        var graph = new joint.dia.graph;        var paper = new joint.dia.paper({       el: this.$('div'),       width: 600,       height: 200,       model: graph,       gridsize: 1       });        var rect = new joint.shapes.basic.rect({       position: { x: 100, y: 30 },       size: { width: 100, height: 30 },       attrs: { rect: { fill: 'blue' }, text: { text: 'my box', fill: 'white' } }       });        var rect2 = rect.clone();       rect2.translate(300);        var link = new joint.dia.link({       source: { id: rect.id },       target: { id: rect2.id }       });        graph.addcells([rect, rect2, link]);   }); }  if (meteor.isserver) {   meteor.startup(function () {     // code run on server @ startup   }); } 

when run following errors:

uncaught typeerror: _.merge not functionjoint.dia.cell.backbone.model.extend.constructor @ joint.js:3831child @ backbone.js:1408(anonymous function) @ joint.js:7436math @ joint.js:39(anonymous function) @ joint.js:44(anonymous function) @ joint.js?518ac863e9f6f1f9a755394c59ad7d562c084829:11194

and

exception tracker afterflush function: referenceerror: joint not defined @ [object object]. (:3000/app/client/meteor:/💻app/client/sampleapp.js:5)

i have tried putting sampleapp.html , sampleapp.js both in project root directory , in /client joint.js in client/

anyone has dealt issue or have idea of how solve referenceerror?

edit: content of jointjs uncaught typeerror occurs:

// joint.dia.cell base model. // --------------------------  joint.dia.cell = backbone.model.extend({      // same backbone.model difference uses _.merge     // instead of _.extend. reason want mixin attributes set in upper classes.     constructor: function(attributes, options) {          var defaults;         var attrs = attributes || {};         this.cid = _.uniqueid('c');         this.attributes = {};         if (options && options.collection) this.collection = options.collection;         if (options && options.parse) attrs = this.parse(attrs, options) || {};         if (defaults = _.result(this, 'defaults')) {             //<custom code>             // replaced call _.defaults _.merge.             attrs = _.merge({}, defaults, attrs);             //</custom code>         }         this.set(attrs, options);         this.changed = {};         this.initialize.apply(this, arguments);     }, 

attrs = _.merge({}, defaults, attrs); line throws error

turns out dependency issue, downgraded backbone , lodash via commandline when installing jointjs-all , fixed issue.

meteor add mxmxmx:jointjs-all --allow-incompatible-update


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -