This seems like such a basic thing for an end-developer to want to accomplish – add a front end javascript library to a Meteor app, and make sure that this library reactively updates…
Most of the guidance on Google on this issue:
https://www.google.com/search?q=meteor+with+3rd+party+javascript
is horribly out of date, confusing, or both.
It would be enormously helpful if there were some canonical guidance on how to do something like this.
Here is my situation:
In my meteor app, I am using this library:
I have the .js file in this directory.
root > client > lib
The problem I’m having however is I can’t figure out where to call this library in my code so it reactively updates with changes to the database.
I have a collection of DIVs like this on the page:
<div class="waveFormJson" id="{{_id}}" </div>
Then, in my template .js file, I call an underscores _.each
function to iterate over the collection and run the Waveform javascript on each one… Here is my code:
Template.videoThumbnails.helpers({
recordings: function () {
var trackId = Session.get('trackId');
var data = Recordings.find().fetch();
_.each(data,function(value,key,obj){
var waveform = new Waveform({
container: document.getElementById(value._id),
});
waveform.update({data: value.waveFormData})
})
return Recordings.find( { 'trackId': trackId }, { sort: { position: -1 }});
},
});
Template.videoThumbnails.onRendered(function(){
var data = Recordings.find().fetch();
_.each(data,function(value,key,obj){
var waveform = new Waveform({
container: document.getElementById(value._id),
});
waveform.update({data: value.waveFormData})
})
})
This is basically working, but eveything seems to run twice, and I just feel like I am not doing this the right way…
thanks