Script Function - fatsecret.addRef(section, element_id)


If the auto_template script URL parameter is set to "false", the predefined templates will not be loaded and you will have to provide your own layout for each canvas. This provides one way to set up the canvas content (the other being fatsecret.writeHolder).
fatsecret.addRef will replace any HTML element on the page with ID of element_id with the specified section (see Canvas Reference for the complete section list for each canvas).



Name Type Description
section String The name of the section to load.
element_id String The ID of the HTML element to replace.


Setting up a simple layout for the food.get canvas.
<script src=""></script>

<div id="search"></div>
<div id="food_title"></div>
<div id="nutrition_panel"></div>

fatsecret.addRef("search", "search");
fatsecret.addRef("foodtitle", "food_title");
fatsecret.addRef("nutritionpanel", "nutrition_panel");
Figure 1: Using fatsecret.addRef to set up a custom layout for the food.get canvas
FatSecret Sites
For Developers

For Professionals

For Everyone

FatSecret Platform API


About FatSecret

© 2021 FatSecret. All rights reserved.