Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script src="{% static 'js/handlebars-v3.0.3.js' %}"></script>
- {# content layout #}
- <script id="handlebarsTemplate" type="text/x-handlebars-template">
- {% include some_string %}
- </script>
- <script>
- $(function(){
- var refresher = function () {
- $.getJSON( "{% url some_json_url %}", function(obj) {
- refresh_timer = obj.refresh_timer * 1000;
- setTimeout(refresher, refresh_timer);
- if (obj.content) {
- // do shit with content and data
- var source = $("#handlebarsTemplate").html();
- var template = Handlebars.compile(source);
- var html = template(obj.content);
- $("#apiTemplate").replaceWith(html);
- }
- });
- };
- setTimeout(refresher, 300); // 0.3 seconds
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment