1

I have some complicated Manipulate[] object that I'd like to make interactively available online. The function CloudDeploy[] seems up for the task, but when I use it I get an online object that does not respond. The sliders and all work fine, but the thing inside just does not update.

The following example reproduces this behavior:

f[x_] := x^2
Manipulate[
 Plot[a f[x], {x, -10, 10}, PlotRange -> {0, 100}],
 {a, 0, 1}]

I get the same behavior regardless of whether I do CloudDeploy[] on the Manipulate[] object only, or on the entire thing. My guess is that it does not work because it's not a single expression, so the solution would be to massage all my functions into the Manipulate[] expression, but that will be arduous to say the least, so I was wondering if there are better ways to go about this.

Julius
  • 337
  • 1
  • 10

1 Answers1

3

You must use the SaveDefinitions option on 'Manipulate' which you should save as a separate variable, i.e.:

m = Manipulate[
 Plot[a f[x], {x, -10, 10}, PlotRange -> {0, 100}], 
 {a, 0, 1}, 
 SaveDefinitions -> True]

CloudDeploy[m, Permissions -> "Public"]

This will automatically store the definitions of any symbols used by the Manipulate into it.

Hope this helps.

Julius
  • 337
  • 1
  • 10
Edmund
  • 42,267
  • 3
  • 51
  • 143
  • What a great tip, thanks! I only found that when I now put the Manipulate[] inside of a CloudDeploy[] the problem persists. However, when I save the Manipulate[] to a variable and do CloudDeploy[] on that it all works out. I hope you don't mind me changing your answer to reflect that. – Julius Jun 02 '19 at 17:01