javascript cross plugin interference
I have created two plugins using Tom McFarlin’s Boilerplate template; both use Javascript and REST. Each works fine independently. Each creates a short code and each short code is used on independent pages. Plugin two contains:
app.PilotHeader = Backbone.View.extend({
el: '#pdf_header',
template: _.template($('#header-template').html()),
initialize: function(){
this.render();
},
render: function(){
this.$el.html(this.template(this.model.toJSON() ));
return this;
}
});
When plugin one runs I get an error on the line template: _.templates… line in plugin two. It can’t find ‘#header-template’ which is in an external HTML file. The template is small enough that I can include it directly as a work around.
Two questions:
1) How do I prevent the javascript code from two different plugins from being intermixed like this?
2) Why can’t Javascript find the template?
Leave an answer