Tuesday, October 11, 2011

A Vague JQuery Template Error

I have been getting an error in JQuery Template, and it's one of those errors that is impossible to debug. It's an issue that can only be fixed by intricately checking your code line by line, character by character. Here is the vague error that I'm getting:
Uncaught SyntaxError: Unexpected token return
Actually, here is the full "stack trace" (if that's what you want to call it) of the error:



I get no js compiler errors or anything, I just get this javascript error when I click on a radio button, but nothing more. My page loads correctly with no problem otherwise. Because of this fact, I was forced to inspect my code over and over and over and over... I removed code, I added code. I reworked my html a few times as well, but still got the error every time. I was literally going in circles trying everything.

The problem? I had an extra jQuery template tag in the very bottom of my script like this:

{{/if}}

At one point I tried combining both states into a single template using {{if}} {{else}} {{/if}}, but then gave up on that idea... Clearly I missed the closing tag and then never bothered to look at the bottom of my script tag when things didn't work. I'ts kind of insane that so much time was wasted on such a silly oversight on my part... Oh the whoa's of a programmer. Back to the grind.

1 comment:

noen08 said...

saved my life, man