Sasha_8
Sasha_8

Reputation: 143

Issue in using template in the view in backbone.js

I have a question related to backbone.js and I need your help. I cannot understand the difference between:

currentCustomersTemplate : currentCustomersTemplate,
maincustomerTemplate : _.template(MainCustomerTemplate),

I mean the template with _. and the one that does not have it! Suppose I have a form (customer form) and inside this form I want to make (separate) forms related to each customer. So every time I add a customer by a button the information for each one goes to the currentCustomer form , which is "in" the main customerForm. (can be like multiple tables inside a bigger table). So I have two templates. Whats the difference of the first and second?

Upvotes: 0

Views: 62

Answers (1)

Ming Chan
Ming Chan

Reputation: 1958

_.template () 'compiles' a raw template into a template object and you can provide different parameters for 'compiling'. You can read underscore template doc in here for more details.

By following what you said, "currentCustomersTemplate" should have been already compiled before and it is a template object. You should see in somewhere prior being referred and there must be _.template() being called already.

Upvotes: 1

Related Questions