diff --git a/js/views/message_detail_view.js b/js/views/message_detail_view.js index 6221e86e..f54e2f64 100644 --- a/js/views/message_detail_view.js +++ b/js/views/message_detail_view.js @@ -19,7 +19,7 @@ var ContactView = Whisper.View.extend({ className: 'contact-detail', - template: $('#contact-detail').html(), + templateName: 'contact-detail', initialize: function(options) { this.conflict = options.conflict; }, diff --git a/js/views/new_group_update_view.js b/js/views/new_group_update_view.js index 2e7706d5..d2807819 100644 --- a/js/views/new_group_update_view.js +++ b/js/views/new_group_update_view.js @@ -20,7 +20,7 @@ Whisper.NewGroupUpdateView = Whisper.View.extend({ tagName: "div", className: "new-group-update-form", - template: $('#new-group-update-form').html(), + templateName: 'new-group-update', initialize: function(options) { this.render(); this.avatarInput = new Whisper.FileInputView({ diff --git a/js/views/recipients_input_view.js b/js/views/recipients_input_view.js index 8a7b7d4f..417371fd 100644 --- a/js/views/recipients_input_view.js +++ b/js/views/recipients_input_view.js @@ -38,7 +38,7 @@ events: { 'click .remove': 'removeModel' }, - template: $('#contact_pill').html(), + templateName: 'contact_pill', initialize: function() { var error = this.model.validate(this.model.attributes); if (error) { @@ -60,7 +60,7 @@ Whisper.RecipientsInputView = Whisper.View.extend({ className: 'recipients-input', - template: $('#recipients-input').html(), + templateName: 'recipients-input', initialize: function(options) { if (options) { this.placeholder = options.placeholder; diff --git a/js/views/whisper_view.js b/js/views/whisper_view.js index c70f22d8..47cdc8ec 100644 --- a/js/views/whisper_view.js +++ b/js/views/whisper_view.js @@ -28,6 +28,12 @@ render_partials: function() { return Whisper.View.Templates; }, + template: function() { + if (this.templateName) { + return Whisper.View.Templates[this.templateName]; + } + return ''; + }, render: function() { var attrs = _.result(this, 'render_attributes', {}); var template = _.result(this, 'template', ''); @@ -51,7 +57,7 @@ var templates = {}; $('script[type="text/x-tmpl-mustache"]').each(function(i, el) { var $el = $(el); - var id = $el.attr('id').replace('-','_'); + var id = $el.attr('id'); templates[id] = $el.html(); }); return templates;