AnsweredAssumed Answered

Dashlet development - onChange for a <select> in handlebars template

Question asked by Michael Jones on Apr 6, 2018
Latest reply on Sep 7, 2018 by Michael Jones

I feel like I've been asking a million questions - the answers have been so helpful and I've made leaps and bounds in my understanding of how to build things into Sugar! Hopefully it won't be long before I'm one of the helpful people with a toolbox full of useful toys to share!


I'm working on a dashlet that displays a list of Accounts assigned to a representative. We've got a time zone field in our data, and I've built the dashlet so that there is a time zone <select> and then the results are displayed in a zebra-striped table below it using handlebars (straight HTML select control in the .hbs template). So far so good... except that I can't figure out how to refresh my table when the select's "onChange" event fires! I've found this kind of thing in the controller .js files in several examples:

this.model.on("change:name", this.loadData, this);

I don't believe the select which I've got in my handlebars template would be included in the model. I expect to be able to do something like this in my controller, maybe in the loadData function:





That simply seems to do nothing at all - the onChange event doesn't seem to fire ever. I also gave this a try, and I suspect this is much closer to the best way to do this:


events: {
      'click [bdr-timezone]': 'this.loadData',


I see some similar code in an example of the php config file:

'events' => array(
      'click' => 'button:custom_button:click',

I feel like I'm so close, and that one or even more than one of these options would work, but I can't seem to get all the way there. Anyone have advice that might point me in the right direction?


Sugar 7.8 Pro