Questions on Interface Builder

Hi,

I’m working on using Flow.js/Contour.js, but at present am still using Interface Builder and trying to customize the generated html.

  1. Is it possible to call JavaScript functions on the data-f-on-click event? For a ‘simulate’ button, I"m trying to first call a JavaScript function and then use the pipe symbol to call the ‘step’ function. When I press the button, I get a “VensimWorkerException: Unsupported procedure” (which possibly answers my question, but I’d like to be sure).

  2. Separately, when I try to advance my simulation, I find that the graph of some variables (on the same web page) is not updated. I have to refresh my browser page to see the change in the variables. This is the html code - Advance by 1 Month

Thanks!

Best,
Aditya

Hi Aditya

  1. Yes. You can use your own jquery as a handler
  2. Are you referring to your Project ‘Test 3 - Savings Rate’?
    If so, please provide us access your project.
    Regards,
    Geromel

Hi Geromel,

This is the project sa-1 (team project, team SD Lab). I’ve made the permissions public, is that enough for you to access it?

The code (for both questions 1 and 2) is in dashboard.html. The project structure is very similar to the default project structure.

thanks!

Aditya

Hi Aditya,

Can you please provide the full URL address of your project?
I am still unable to access.
You can send the URL address privately by emailing to support@forio.com

Regards,
Geromel Grate

Hi Aditya,

Just as a quick note on “1”, what you need to do is remove the data-f-on-click and something like

$('mybutton').on('click', function () {
    myjsfunction();
    Flow.channel.publish("operation:step");
});

As an aside, the interface builder is currently using a “pre-release” 1.0 version of Flow.js which doesn’t have good documentation yet; the last published version is 0.12.0 so the equivalent “publish” code for that will be a bit different. If you’re starting with using FlowJS on a new project I’d recommend using 0.12.0 until we finalize the new version, if not you can continue using 1.0 and we’ll be happy to guide through forum posts until we get the docs out.

-Naren

Hi,

Geromel, I will email support with the details.

Naren, I’m using onclick instead of data-f-on-click to call a js function to do some checks, and from there calling the step operation through the run service api which works fine. Your method is probably better js. (I’m teaching myself js as I work with flow.js/contour.js/epicenter.js)
I did try changing the flow.js library version to 0.12.0, but I ran into an error from the library, so I think I’ll stay with 1.0 for now.

  1. The documentation states that the reset operation cannot be called from the run service api, so if I wanted to call it from flow.js it would be Flow.channel.publish(“operation:reset”); ? This does not appear to be having the intended effect.
  2. Separately, I’d like to use the epicenter api’s as much as possible - since I cannot do a reset operation using the epicenter run service api, would it’s equivalence be calling a new instance of a run manager?

Thanks,
Aditya

Hi Aditya,

re: 1 Flow.channel.publish(“operation:reset”) should give you a new run.

re: 2 If you’re using FlowJs I’d encourage staying within doing things with FlowJS as much as possible, and only stepping out to use EpicenterJS when you know there’s something you can’t accomplish otherwise - just as a matter of simplicity.

That said, it is possible to reset from the RunManager using the ‘reset’ function as documented here https://forio.com/epicenter/docs/public/api_adapters/generated/run-manager/ – the only catch is you’ll need to make sure you’re resetting the “correct” run (i.e. the same run which has your decisions on it), which is why the “operations:reset” way is better as that takes care of it for you. Can you elaborate on what didn’t work with that?

btw, these are really good questions! We also appreciate that you went through our documentation in detail :smiley: If you have any feedback on things you found confusing/ what we can do better that’ll be useful as well.

Geromel, Naren,

I’ve separately sent an email to support@forio.com.

Naren,

  1. When I try Flow.channel.publish(“operation:reset”); I get a RuntimeError:No actions to process error
  2. Noted.

Aditya

Hi Aditya,

Sorry, this was a typo on my part! it should be “operations:reset” (plural operations)

-Naren

Thanks for the update.

On the subject of resetting and starting a new run -

I’ve added the following code within :smile:

Doesn’t this mean that every time I reload the page, a new run is initialized? If so, I must think of how to get around it - I wouldn’t want the end-user to be able to do this.

Regards,
Aditya

Correct.
The Reset button will initialize a new run.

Hi Aditya,

re: “Doesn’t this mean that every time I reload the page, a new run is initialized” - it depends on where you have the code. If you’re calling the reset function everytime the page loads then yes (and is hence a bad idea). If it’s within a click handler then it’s fine, and you can always have a seperate ‘admin.html’ page which is not available to the end user if you want to control this.

Can you let us know more about your use-case? i.e. what’s the expected behavior / functionality that you’re trying to build out?

-Naren