Page 1 of 1
Assigning an updated event handler to a supplier control
Posted: Tue Jul 19, 2022 3:34 am
by becksetaylor
I'm trying out making two analyses available within a module, and I see that I need to update the javascript file manually in order to make the second analysis work, but I don't see any explicit examples of what that would look like... the examples below from the tutorial make me feel like I'm missing a step! Partly because I'm not sure what I need to tell it to do!!
module.exports = {
// event handlers and functions are defined here
// this is an example of an event handler
view_loaded: function(ui, event) {
// do something
},
// this is another example of an event handler
ttestType_changed: function(ui, event) {
let value = this.calculateValue();
// do something
},
// this is an example of an auxiliary function
calculateValue: function() {
// do something
}
};
I'm just feeling my way around and would appreciate some guidance
Re: Assigning an updated event handler to a supplier control
Posted: Wed Jul 20, 2022 12:26 am
by jonathon
let me attend damo to this.
cheers
Re: Assigning an updated event handler to a supplier control
Posted: Wed Jul 20, 2022 2:12 am
by dropmann
Hi, so what is it that you are trying to do that requires you to add javascript? Sometimes its easier to work through the exact problem to understand where you are getting stuck. I see the subject refers to wanting to assign an update event handler to a supplier. In the tutorial under the title 'Events' it describes how to add an event handler to a specific control event. So for a supplier control named bob the event handler for the 'updated' event would look like:
Code: Select all
bob_updated: function(ui, event) {
let value = ui.bob.value();
// do something in response to the event
}
When compiled, the compiler will attach this function to the event 'updated' of the control 'bob'.
Re: Assigning an updated event handler to a supplier control
Posted: Wed Jul 20, 2022 2:53 am
by becksetaylor
Hi! Thanks for your reply!
Ultimately when I build my module, I would like to have two analyses (and their within-analysis options) available to the user, so I am trying things out by extending on the tutorial at the moment in order to practice with simple(ish) things.
I successfully built the ttest from the tutorial, and am trying to add another analysis option to my module, I thought I would start by adding a simple linear regression and a plot. When I try to run the regression analysis I get the errors telling me I need to add an event handler. Of course all this may be entirely the wrong way to go about things!
It seems to me that what I'm trying to do is link up the correct analysis with that option on the UI. I also am not sure whether I should be making this change in the file associated with the first analysis or the new one that I've added.
I hope this makes sense! Thanks for taking the time to help a novice!
Cheers,
Rebecca
Re: Assigning an updated event handler to a supplier control
Posted: Wed Jul 20, 2022 5:20 am
by jonathon
When I try to run the regression analysis I get the errors telling me I need to add an event handler.
could you provide a screenshot of this?
with thanks
Re: Assigning an updated event handler to a supplier control
Posted: Wed Jul 20, 2022 5:32 am
by dropmann
Ok, i think i may understand what is happening. So there are two supplier controls. 'Supplier' which is a generic supplier of anything. There is also a 'VariableSupplier' which has a back-end to handle all variable populating and updating. If you are using the 'Supplier' then it needs the event handler attached so that it can be manually populated/updated with content. The 'VariableSupplier' does this all automatically, unless you set the 'populate: manual', which will cause this error to be thrown as well. Hope that helps.
Re: Assigning an updated event handler to a supplier control
Posted: Wed Jul 20, 2022 5:35 am
by dropmann
Information regarding the finer details of suppliers is not yet in the tutorials and explains how you couldn't figure it out.
Re: Assigning an updated event handler to a supplier control
Posted: Wed Jul 20, 2022 7:43 am
by becksetaylor
jonathon wrote:When I try to run the regression analysis I get the errors telling me I need to add an event handler.
could you provide a screenshot of this?
with thanks
Here you go!

- Error message.png (137.44 KiB) Viewed 11634 times
Re: Assigning an updated event handler to a supplier control
Posted: Wed Jul 20, 2022 7:45 am
by becksetaylor
dropmann wrote:Ok, i think i may understand what is happening. So there are two supplier controls. 'Supplier' which is a generic supplier of anything. There is also a 'VariableSupplier' which has a back-end to handle all variable populating and updating. If you are using the 'Supplier' then it needs the event handler attached so that it can be manually populated/updated with content. The 'VariableSupplier' does this all automatically, unless you set the 'populate: manual', which will cause this error to be thrown as well. Hope that helps.
Yes, I think this is right, and as you say below, there's no information added yet on how to do it. I've never tried to do something like this before, so don't have any experience to fall back on to figure it out!
