Listening to pens

I would like to achieve:

  • after the template is rendered, attached to the submit form to add a spinner
  • before setting the template, delete the counter, if present

I think that would be easy to achieve if there was a way to bind Handlebars rendering. I have not yet found clues that this will be possible.

The way I'm trying to solve this may not be the case, so feel free to suggest other remedies.

This is a one-page application using Davis for routing and jQuery for manipulating the DOM.

+3
source share
1 answer

submit jQuery $(document).on("submit", "form", function(event) { ... });. , DOM.

jQuery, . html() . , . . $("#content").bind("render", function() { /* REMOVE SPINNER */ }); $("#content").render(/* WHATEVER IT TAKES TO GET HTML OUT OF HANDLEBARS */);. , , :

(function($) {
  $.fn.render = function(htmlString) {
    var selector = this;
    selector.html(htmlString);
    selector.trigger("render");
  };
})(jQuery);

fiddle, ( Handlebars).

+2

All Articles