I have been trying to make a custom handlebars helper
This is the helper file
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* Handlebars helpers.
*
* These functions are to be used in handlebars templates.
* @class Handlebars.helpers
* @singleton
*/
(function (app) {
app.events.on("app:init", function () {
/**
* convert a string to upper case
*/
Handlebars.registerHelper('tristate', function (value) {
let markup = '';
switch (value) {
case '1':
markup = "CHECKED";
break;
case '2':
markup = "indeterminate=1";
Then I have my JSGroupings file
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
//Loop through the groupings to find grouping file you want to append to
foreach ($js_groupings as $key => $groupings) {
foreach ($groupings as $file => $target) {
//if the target grouping is found
if ($target == 'include/javascript/sugar_grp7.min.js') {
//append the custom JavaScript file
$js_groupings[$key]['custom/javascript/jquery.tristate.js'] = 'include/javascript/sugar_grp7.min.js';
$js_groupings[$key]['custom/javascript/handleBar-helpers.js'] = 'include/javascript/sugar_grp7.min.js';
break;
}
}
}
And this is in the HBS file
Fullscreen
1
2
3
<input id={{this.id}} type="checkbox" checkedvalue="1" uncheckedvalue="0"
indeterminatevalue="2" class="row-checkbox" data-name="tristate"
data-populated-row="{{this.populated_row}}" {{tristate this.checked}}"/>
It never seems to run the helper at all. I have cleared the cache/, run the repairs, verified that the JS is where it should be in the sugar_grp7.min.js file.
I also cant find where the {{log this}} is logging to. Its not the console or the Sugar log file.