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

can.Observe.attr() issue

$
0
0
Hi!

This issue is illustrated in this fiddle.

I'm experiencing an issue with can.Observe.attr() when passing another Observe as parameter, such as in line 11:

  1. can.Model('Entry', {
  2.   findAll: 'GET /entries',
  3.   curr: new can.Observe({}),
  4.   list: new can.Observe.List([])
  5. }, {});
  6.  
  7. // Inside a can.Control method:
  8. Entry.findAll({}, function(entries) {
  9.   Entry.list.replace(entries);
  10.   if (entries.attr('length') > 0) {
  11.     Entry.curr.attr(entries[0]);
  12.   }
  13. }

I get two errors. The first call to attr() results in:

TypeError: name.split is not a function @ http://canjs.us/release/latest/can.jquery.js:141

Then, all subsequent calls to attr() result in:

TypeError: curVal.attr is not a function @ http://canjs.us/release/latest/can.jquery.js:772

One solution I found is calling Entry.curr.attr(entries[0].attr()); but I think Entry.curr.attr(entries[0]); should work.

Hearty thanks for any help anyone can provide =)

P.S.: Comments regarding other aspects of the fiddle are as much appreciated!

-- Pablo Aguiar (scorphus)

Viewing all articles
Browse latest Browse all 3491

Trending Articles