Skip to content

Instantly share code, notes, and snippets.

@superchris
Created March 14, 2011 02:07
Show Gist options
  • Save superchris/868660 to your computer and use it in GitHub Desktop.
Save superchris/868660 to your computer and use it in GitHub Desktop.
spec helper function that loads a view template into the jasmine jquery fixture
jasmine.Fixtures.prototype.loadTemplate_ = function(template) {
var templateUrl = "/backbone/templates/" + template;
var self = this;
$.ajax({
async: false, // must be synchronous to guarantee that no tests are run before fixture is loaded
cache: false,
dataType: 'html',
url: templateUrl,
success: function(data) {
$('#' + self.containerId).append(data);
}
});
};
function loadTemplate(template) {
jasmine.getFixtures().loadTemplate_(template);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment