# Why is my dynamic slider no longer working?

This used to work but I accidentally made some unrecoverable edits and it stopped displaying. It supposed to adjust the background color of the current notebook. Please have a look and see what is wrong.

notebookBackgroundGraySlider[] := Module[{x = 1},
Slider[Dynamic[x]];
SetOptions[EvaluationNotebook[],
Background -> Dynamic[RGBColor[x, x, x]]];
];

• With 1; 2 the 1 won't be displayed either.
– Kuba
Jun 25 '20 at 8:55

I'm guessing you want this?

notebookBackgroundGraySlider[] := DynamicModule[{x = 1},
Slider[
Dynamic[x,
Function[
x = #;
SetOptions[EvaluationNotebook[], Background -> Dynamic[RGBColor[x, x, x]]]
]
]
]
]

• If you SetOptions each time then there's no need for Dynamic in the option. Regardless of where and when SetOptions is done the Dynamic with a local variable can lead to troubles in a new session. But maybe it does not matter, depends on the context.
– Kuba
Jun 25 '20 at 9:09
• @SjoerdSmit it looks a little different from the way I had it before (when it worked) but who cares this works perfect. Thank you so much. Jun 25 '20 at 9:14
• @Kuba True. I haven't tested how this persists between sessions or anything, so it will probably need tweaking. Jun 25 '20 at 9:35