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

Re : Conventions, strategy, syntax, file extension for external mustache views/templates?

$
0
0
Still curious what the best approach is to act on return data.  I'm having a little trouble with how Deferred methods act on what is returned from a model's findAll.

For instance:
  1. var SomeModel = can.Model.extend({
  2.       findAll: 'GET some/path/to/data.json'
  3. });

  1. var mod = SomeModel.findAll().then(function(data) {
  2.       console.log( data ); // Nothing ... 
  3. });
  4. console.log( mod ); // logs the Deferred obj
In this case the data is a local static json file and I get nothing passed into the $.then callback.  On second look, having the findAll path be an actual api endpoint does return data, an array.  Not sure why local json file wouldn't respond same way.

Update:  findAll() is picky about data structure?  If it's a single object data won't be passed?  Changed the above to findOne() for the data which is a single object and it works.

Viewing all articles
Browse latest Browse all 3491

Trending Articles