Kasper Reijnders
  • Werk
    • Frontend
    • Grexx
    • Incentro
      • Thinkwise
      • Alfresco
  • Muziek
  • Thoughts
  • Over mij

26 oktober 2016Frontend

loadPage

/**
 * Load a template and put it in a container.
 * @param {String} templateUrl        The absolute path to the template
 * @param {String} templateId         The id of the chosen template
 * @param {jQuery} $templateContainer Empty container where the template will be placed in
 * @param {Object} viewData           The data that is loaded in the template
 *
 * @TODO: this must be refactored to a wrapper function for Mustache
 */
function loadPage(templateUrl, templateId, $templateContainer, viewData) {
    var defer = new $.Deferred();
    $.get(templateUrl, function(templates) {
        var template = $(templates).filter(templateId).html();
        var output = M.render(template, viewData);
        $templateContainer.html(output);
        defer.resolve();
    });
    return defer.promise();
}

← get url parametersTop tracks 2016 →
Kasper Reijnders

Persoonlijk logboek, sinds 2006. Notities over low-code, frontend, muziek en de buitenlucht.

Elders
Tools
  • Campbase
  • Stafkaarten
  • JSONLint
Onderwerpen
  • Alfresco
  • Frontend
  • Gedichten
  • Grexx
  • Incentro
  • Lastfm
  • Muziek
  • Scouting
  • Site
  • Thinkwise
  • Werk

© Kasper Reijnders

Gebouwd met Boslicht.