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

Unbinding models combined with the attributes plugin doesn't work

$
0
0
Hi all,

I have a problem by using attributes plugin and live binding.

Define models:
  1. var Page = can.Model('Models.Page', {
  2.     attributes: {
  3.         Texts: 'Models.Text.models'
  4.     },
  5.     findOne : '/demo/canjs/page/{id}'
  6. }, {});
  7. var Text = can.Model('Models.Text', {
  8.     findOne : '/demo/canjs/text/{id}'
  9. }, {});

now I can use a page object in ejs, e.q.:

  1. <%= page.attr('title') %>
  2. <% page.attr('Texts').each(function( text ) { %>
  3.     <%= text.attr('content') %>
  4. <% }) %>

The internal counter "_bindings"  of displayed text object will set to 2.

If you remove the view, the page object will removed from internal page-store. but the text object still remains in the internal text-store with _bindings = 1.

I tryed some subtemplates to, but I got the same issue. By using many objects I will get a memory leak.

Is there some workaround, or do I understood something wrong?

Thank you for your helping.


Viewing all articles
Browse latest Browse all 3491

Trending Articles