Created
March 31, 2015 02:06
-
-
Save novascreen/8f77e80fc9810da75283 to your computer and use it in GitHub Desktop.
Let's you distribute templateNodes to Shadow DOM style insertion points in your knockout components
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
define(['jquery'], function ($) { | |
return function (componentInfo) { | |
var $templateNodes = $(componentInfo.templateNodes) | |
$(componentInfo.element).find('content[select]').each(function () { | |
var $placeholder = $(this), | |
query = $placeholder.attr('select'), | |
$content = $templateNodes.filter(query) | |
$templateNodes = $templateNodes.not($content) | |
$placeholder.replaceWith($content) | |
}) | |
$(componentInfo.element).find('content').replaceWith($templateNodes) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment