Skip to content

Instantly share code, notes, and snippets.

@superchris
Created March 14, 2011 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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