I am creating a comment system with knockout.js and I am having some problems with the fact that templates work with our existing jQuery functions.
One example is the creation of comment dates. I wrote a jQuery function that forces data to go from 5-5-2012to 2 Days ago. For instance:
<ul data-bind="foreach: Comments">
<li data-bind="attr: { id: Id }" class="Comment">
<div data-bind="text: DateCreated" class="prettyDate"></div>
...
</li>
</ul>
<script type="text/javascript">
$(function(){
$(".prettyDate").prettify();
});
</script>
With this code, when I add a new comment dynamically, the date remains in the format 5-5-2012. There are several other custom jQuery functions that act on duplicate data that is now dynamically created by knockout (usually by class-based selection).
How can I apply these custom jQuery functions to dynamic data generated by knockout.js?