Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

can.view doesn't render deferred data

$
0
0
Hi All,

I'm facing with the following problem: Let's have a controller which creates and displays a modal edit form.
  1. var EditForm = can.Control.extend({
  2. defaults: {
  3. view: config.templateurl + DASH + "editform.mustache",
  4. customerTemplate: "customerTemplate",
  5. workloadTemplate: "workloadTemplate",
  6. engineerTemplate: "engineerTemplate",
  7. priorityTemplate: "priorityTemplate",
  8. sourceTemplate: "sourceTemplate",
  9. statusTemplate: "statusTemplate",
  10. },
  11. },{
  12. init: function(element, options){
  13. var self = this;
  14. self.element.append(self.options.view, { assignment: Assignments.findOne({id: options.id),selects: selects, customers: customers, engineers: engineers } );
  15. }
  16. });
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: 
  1. init: function(element, options){
  2. var self = this;
  3. can.view(self.options.view, { assignment: Assignments.findOne({id: options.id}),selects: selects, customers:customers,                               engineers: engineers })
  4. .then(function(frag){ self.element.html(frag); });
  5. }
I wonder, why does the first version not working?

Viewing all articles
Browse latest Browse all 3491

Trending Articles