Intermittent TypeError on Form Load

Status
Not open for further replies.

njbair

New Member
I have one particular form which works fine 90% of the time, but the rest of the time I receive an error on load that looks like this:
Code:
Uncaught TypeError: Object [object Object] has no method 'setOptions'

Here's the URL: https://www.isee.bad-dev.com/publications/subscribe

The call stack shows this is occurring on Class.initialize, during the creation of the FbForm object in media/com_fabrik/js/fabrik-min.js. Sometimes it occurs on other resources as well, including element-min.js and tipsBootStrapMock-min.js.

I do have a lot of custom JS on this particular script, but nothing I can see that might interfere with the creation of the form object. The particularly vexing part is that it only happens every once in a while, making it hard to debug.

The intermittent nature of the issue leads me to believe that something is being triggered before all the libs are fully loaded, but most of the time the network is fast enough that the problem doesn't present itself. I just can't figure out why only this one form would be affected.

UPDATE:
Apparently these intermittent errors are eventually followed up by a require.js timeout error:
Code:
Uncaught Error: Load timeout for modules: fab/window-min,fab/elementlist-min,element/checkbox/checkbox-min
http://requirejs.org/docs/errors.html#timeout

So, as suspected, a script is firing off before its dependencies are met, rather than via a callback.

I've got Debug JS enabled in Fabrik options.
 
I am getting the first error every time I load this page rather than intermittently.

I suspect that the cause might be code in https://www.isee.bad-dev.com/components/com_fabrik/js/19.js specifically the function Options which is overwriting the Mootools Options class (which contains setOptions) with this function.

You might want to consider wrapping these in a worker class e.g. start your file with something like:
JavaScript:
var isee_worker_19 = new Class ({
Then refer to the functions you need with e.g. isee_worker_19.Options()

Hope this helps.

S
 
Late reply, I know, but thank you for your help. This was indeed the issue. I've refactored all my form scripts to class them out and everything works like a charm!
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top