Last active
December 29, 2015 19:59
-
-
Save jdittrich/7720927 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
For injecting additional pages in an existing jqueryMobile-Page | |
*/ | |
$(function(){ | |
(function(){ | |
var data = $.parseJSON( $("#template-data").html());//gets the string and turns it into a JSON | |
var template = $("#template").html(); //gets the mustache template; | |
var compiledTemplate = Handlebars.compile(template); //precompilation of the template | |
//replaceWith() is used because I dont get DOMFragements to work and I dont want to replace the whole content. | |
//renders the template and returns a HTML-String | |
$("#placeholder").replaceWith(compiledTemplate(data)); | |
$("#container").trigger("create"); //triggers the enhancement of inserted HTML | |
}()) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment