WeBWorK Main Forum

MathQuill and brackets

Re: MathQuill and brackets

by Glenn Rice -
Number of replies: 0
I ran into the same problem when coding the MathQuill answers and toolbar, and ended up using a few globals. In fact the pull request that stems from this discussion utilizes one of them. The answerQuills object that stores all of the MathQuill answer boxes for the page. I also designed a method to set separate options for each answer that uses global variables. The variable is something like MaThQuIlL_AnSwEr0001_Opts, of course with AnSwEr0001 replaced with the answer rule name. I am still trying to figure out a better way to do this, and to get a MathObject context to set the option. For example, parserRoot should set the rootsAreExponents option to be false.

Globals of course can cause possible conflicts, but in the end it is impossible to avoid globals entirely. Any javascript library must have at least one global object. If designed correctly you can avoid other globals. Ideally any options for the library can be set when the library is first loaded.