Murilo Venturoso
Murilo Venturoso

Reputation: 359

Get the HTML content of a template Meteor

How do I get the html content of a template? For example, I have the following template:

<template name="test">
<div id="example">
    <strong>This is a test.</strong>
</div> <button id="btn">Get</button></template>

I need the event click of button the HTML contents of the div # example is captured. it possible?

Upvotes: 1

Views: 577

Answers (3)

user773156
user773156

Reputation:

As of Meteor 1.x, you can use Blaze.toHTML(). It returns the HTML of the given Template as a String.

Upvotes: 1

Erez Hochman
Erez Hochman

Reputation: 1708

If you assign the click event using Template.test.events you should have all the data that template describess in your "this".

Upvotes: 0

Tarang
Tarang

Reputation: 75945

You could use JQuery (already built into meteor) for this

var html = $('#example').html();

Upvotes: 1

Related Questions