Created
March 14, 2011 02:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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