Weird behavior when adding and editing blocks

Permalink
I've got a c5 v5.4.1.1 site I'm building with a custom theme. It is basically working smoothly except when I add blocks to pages or edit existing blocks.

When I add a block (I've tried the basic content block, autonav, and search) to a page, concrete/startup/process.php returns a JSON-encoded array to the AJAX-submitted form handler that looks like this:

{"aID":"12","arHandle":"Main","cID":"73","error":false,"bID":"9"}

The error:false is because it successfully added the block. (Yay! :)

The problem is, the ccm_parseBlockResponse function in concrete/js/ccm.ui.js then proceeds to try to do this:

resp = eval('(' + r + ')');

Where r is the above-mentioned JSON-encoded array, and expecting the result to be an object with attributes corresponding to the JSON-encoded results array. The eval fails, throwing an exception, generating a popup displaying the JSON-encoded array, and then neglecting to close the editor and move on with things.

After some research and as an experiment, I replaced the eval with simply resp = r; and things work as expected. (Well, except it doesn't reload the page so the added block doesn't show up until you refresh...) I hesitate to just call that good, however, as I expect the eval is there for a reason! :)

It seems like the parties involved are behaving reasonably except that these two functions aren't communicating in an agreed-upon way - concrete/startup/process.php thinks it's supposed to send a JSON-encoded results array but the ccm_parseBlockResponse function in concrete/js/ccm.ui.js is expecting it in a different format. Why would that be? Is the missing piece some third actor that is failing to inform one of the those two the format to use? Or to assign a different results handler?

From my research, it sounds like this kind of issue can occur when the form data isn't being submitted properly, specific examples suggest either failed-but-undetected form validation or options without an explicit value assigned but nothing looks fishy to me in the data being submitted.

Any thoughts on where the disconnect could be and what could be causing it?

 
nklatt replied on at Permalink Best Answer Reply
Okay, I've found the issue in a script embedded in the theme by the designer.

If a moderator wants to delete this thread, I think that would be appropriate.

Sorry for cluttering the board. On the other hand, thanks for being here. :)