Hi All,
I'm facing with the following problem: Let's have a controller which creates and displays a modal edit form.
- var EditForm = can.Control.extend({
- defaults: {
- view: config.templateurl + DASH + "editform.mustache",
- customerTemplate: "customerTemplate",
- workloadTemplate: "workloadTemplate",
- engineerTemplate: "engineerTemplate",
- priorityTemplate: "priorityTemplate",
- sourceTemplate: "sourceTemplate",
- statusTemplate: "statusTemplate",
- },
- },{
- init: function(element, options){
- var self = this;
- self.element.append(self.options.view, { assignment: Assignments.findOne({id: options.id),selects: selects, customers: customers, engineers: engineers } );
- }
- });
The problem is that the view renders the embedded data (selects, customers, engineers), which already existing, but doesn't render the deferred data (assignment), I get the placeholders, like "__||__" instead.
The deferred data resolved, If I debug the mustache template, I can see it in the scope object.
At last I found the following workaround:
- init: function(element, options){
- var self = this;
- can.view(self.options.view, { assignment: Assignments.findOne({id: options.id}),selects: selects, customers:customers, engineers: engineers })
- .then(function(frag){ self.element.html(frag); });
- }
I wonder, why does the first version not working?