How can I define a Bright Javascript Helper to run only on a single page?
Sometimes, it is useful to define a Bright helper on a single page. Here's something that can be done right in the WordPress post body:
In this case, we are going to alter some of the css generated by a template after the template generates:
<script>
Bright.addHook('after_load',function() {
jQuery("table.bright-results-matrix").each(function () {
jQuery('div#secondary').css('display','none');
});
});
</script>
Note the use of after_load hook. This means the javascript is hooked after the templates render. To run javascript before templates render, use before_load:
<script>
Bright.addHook('before_load',function() {
Bright.helper('myhelper',function(text) {
return 'I am in a helper with text' + text;
});
});
</script>