uncaught TypeError: Cannot call method 'replace' of undefined backbone.js

前端 未结 1 745
走了就别回头了
走了就别回头了 2020-12-03 17:56

I \'m trying to develop a simple RSS app using backbone.js. I \'m using this backbone.js tutorial. I \'m getting the following error, on line 2(template), when defining the

1条回答
  •  长情又很酷
    2020-12-03 18:10

    You're getting your error right here:

    template: _.template($('#tmpl_sourcelist').html()),
    

    Part of _.template's internals involves calling String#replace on the uncompiled template text on the way to producing the compiled template function. That particular error usually means that you're effectively saying this:

    _.template(undefined)
    

    That can happen if there is no #tmpl_sourcelist in the DOM when you say $('#tmpl_sourcelist').html().

    There are a few simple solutions:

    1. Adjust your
提交回复
热议问题