0

I'm making a massive multi page backbone site.

I'm sometimes re-using collections and views across multiple pages of the site, as if they were controls. I've now done something which is coming up with errors like this,

Cannot read property 'c18' of undefined

At the moment, the c18 is always the same.

I'm also using backbone relational.

Any ideas anyone?

Derick Bailey
  • 72,004
  • 22
  • 206
  • 219
Chris Barry
  • 4,564
  • 7
  • 54
  • 89
  • The code is almost too massive to post here, about 50 separate js files for all the different pages and sections. I was hoping someone might shed some light on having seen this before? It seems to happen when switching between different collections, but on the same page. – Chris Barry Jun 13 '12 at 11:37
  • OK, on doing some more testing, I do think the problem could be incomplete data coming from the db. It's pretty complex with lots of filter options and backbone relational stuff going on. – Chris Barry Jun 13 '12 at 11:55
  • 2
    c18 sounds like a backbone object instance id value and not a backbone object itself – Alex Jun 13 '12 at 12:05
  • Yes indeed, it stands for clientId, and I think I've solved it by making sure I passed objects that were children in BB relational. But it doesn't quite make sense how it could error about something it doesn't know about, becuase it was being passed empty. Hmm. Maybe I was sorting objects incorrectly or something. If I get to the bottom of it, I'll let you know. – Chris Barry Jun 14 '12 at 13:17

1 Answers1

1

I had weird errors happening when a view was closed before it finished rendering. In your case, it could be that a model was removed before a view finished rendering.

In the future, you could debug this by hacking the Backbone code and printing the CID on View and Model initialization (in the constructor). At least this way you'd know what type of object c18 is.

Tony Abou-Assaleh
  • 3,000
  • 2
  • 25
  • 37