Book Image

Meteor Cookbook

By : Isaac Strack
Book Image

Meteor Cookbook

By: Isaac Strack

Overview of this book

Table of Contents (19 chapters)
Meteor Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using reactivity with HTML attributes


One of the hidden gems in Meteor is the extremely granular control you have over how HTML is rendered. Blaze was designed in such a way that you can modify, add, or remove HTML element attributes dynamically without affecting anything else in the DOM! This recipe will walk you through the use of dynamic, reactive data inside element attributes.

Getting ready

We will use the codebase from the Creating custom components recipe, the previous recipe in this chapter. Please follow that recipe first or download the corresponding codebase.

How to do it…

Proceed with the following steps to use reactivity with HTML attributes:

  1. We first need to create a new navcolor template. Open navbar.html in your [project root]/client folder and add the following code:

    <template name="navcolor">
        <div class="nav navbar-form navbar-right">
            <input type="checkbox" id='bgCheck' checked="{{useBG}}"/>
            <input type="text" id='bgColor' placeholder...