0
var metrobusApp = metrobusApp || {Views:{},Models:{},Routes:{},JST:{}};
metrobusApp.JST["/main"] = _.template('
    <label>Introduzca el codigo de la tarjeta</label>
    <input type="text" id="txtCodigo"/>
    <input type="submit" id="btnSubmit"/>
    ');

metrobusApp.JST["/consultar/:id"] = _.template('
    <p>Id: <%tarjeta.get("id")%></p>
    <p>Saldo: <%tarjeta.get("saldo")%></p>
    <p>Estado de Contrato: <%tarjeta.get("estadoContrato")%></p>
    <p>Fecha y Hora: <%tarjeta.get("tiempo").fecha%> <%tarjeta.get("tiempo").hora%></p>
    ');

I am doing an app with backbone and phonegap. but first i want to test it in the browser then in the file of the templates this error appears: Uncaught SyntaxError: Unexpected token ILLEGAL

What i am doing wrong? the error appears at line 2.

4

1 に答える 1

4

\JavaScriptでは、文字列リテラルが複数行の場合に備えて、文字列リテラルの各行の最後に配置する必要があります

お気に入り

metrobusApp.JST["/main"] = _.template('\
    <label>Introduzca el codigo de la tarjeta</label>\
    <input type="text" id="txtCodigo"/>\
    <input type="submit" id="btnSubmit"/>\
    ');

または、次のように複数の連結文字列に分割できます。

'foo' + 
'bar' + 
'baz'
于 2012-07-10T05:24:16.423 に答える