I have been trying to use lodash.js in Meteor js and will need help in doing this. I have tried all methods of appending external file to meteor but still the same error.
I have this dropdown with search on codepen I want to use in a template. I have been on this for more than 8 hours today and yet to figure out what to do. Also, I added this package to Meteor when appending urls of external js files did not work and the error persists. This is my implementation:
<template name="multiselect">
<div class="instructions">(Click to expand and select states to filter)</div>
<div class="dropdown-container" style="width: 100%;">
<div class="dropdown-button noselect">
<div class="dropdown-label">States</div>
<div class="dropdown-quantity">(<span class="quantity">Any</span>)</div>
<i class="fa fa-filter"></i>
</div>
<div class="dropdown-list" style="display: none;">
<input type="search" placeholder="Search states" class="dropdown-search"/>
<ul></ul>
</div>
</div>
</template>
This is the error i keep getting:
VM31646:100Uncaught ReferenceError: startCase is not defined(anonymous function) @ VM31646:100_.each._.forEach @ underscore.js?hash=cde485f…:149(anonymous function) @ VM31646:99DOMRange._insertNodeWithHooks @ blaze.js?hash=f33d3df…:407Blaze._DOMRange._insertNodeWithHooks @ client.coffee:17DOMRange._insert @ blaze.js?hash=f33d3df…:376DOMRange.attach @ blaze.js?hash=f33d3df…:453Blaze._DOMRange.attach @ client.coffee:57DOMRange._insert @ blaze.js?hash=f33d3df…:371DOMRange.attach @ blaze.js?hash=f33d3df…:453Blaze._DOMRange.attach @ client.coffee:57Blaze.render @ blaze.js?hash=f33d3df…:2373_render @ kadira_blaze-layout.js?hash=dbd1396…:204(anonymous function) @ kadira_blaze-layout.js?hash=dbd1396…:77_.extend.withValue @ meteor.js?hash=27829e9…:1077(anonymous function) @ meteor.js?hash=27829e9…:464(anonymous function) @ meteor.js?hash=27829e9…:1105onGlobalMessage @ meteor.js?hash=27829e9…:401
This works fine without using it in Meteor.
I suspect you have the underscore
library in your Meteor project, which has the same "_
" shorthand as lodash does and overrides it. A way to go around that is to use the meteor-lodash package, which allows you to call lodash
functions like this:
lodash.each(usStates, function(s) {
s.capName = lodash.startCase(s.name.toLowerCase());
$('ul').append(stateTemplate(s));
});