blueimp/JavaScript-Templates

Uncaught Error: Syntax error, unrecognized expression:

Closed this issue · 6 comments

If you will upgrade to jQuery 1.9 and use custom templates, you will face this error:
Uncaught Error: Syntax error, unrecognized expression:

This causes
line: 59:template = tplContainer.html();
Change to:
template = $($.parseHTML(tplContainer.html()));

http://bugs.jquery.com/ticket/13223

Hitting this same issue with jQuery 1.9.1 which comes with the latest version of the jquery-rails gem.

This also breaks jquery-fileupload-rails gem

Thanks for your report guys, but this is apparently not a bug in the JavaScript Templates script, therefore I'll close this issue.

This is definitely not a bug, but a huge compatibility issue for jQuery 1.9.x users . I wish I had enough JS experience to fix this.

VaclovasV already posted the solution in his comment above.
If your template contains whitespace at the beginning, you'll have to wrap your template result content in a $.parseHTML() call (see the referenced bug report here: http://bugs.jquery.com/ticket/13223).

Please also have a look here: #15
and here: #17

    _._template = _.template;
    _.template = function(template){
      return function(options){
        return $.parseHTML(_._template(template, options));
      };
    };

I never call

_.template(template, obj);
directly so this works for me