Uploaded image for project: 'Appcelerator - INBOX'
  1. Appcelerator - INBOX
  2. AC-2633

Alloy collection.get returning undefined

    Details

    • Type: Bug
    • Status: Resolved
    • Resolution: Not Our Bug
    • Affects Version/s: None
    • Component/s: Alloy
    • Environment:

      Mac OS 10.8.3, Titanium 3.1.0.GA, Alloy 1.1.2, iOS SDK 6.1, Titanium Studio build: 3.1.1.201305101132

      Description

      If I have a collection called catalogs and I want to get a model (id 1234) from that collection by id, based off of the documentation for backbone.js, I believe I should be able to:

      var selectedCatalogID = '1234'
      var catalog = null; 
      catalog = catalogs.get(selectedCatalogID);
      

      but when I introspect catalog after this runs, its value is undefined;

      A work around I have been using is:

      var selectedCatalogID = '1234'
      var catalog = null; 
      for (var i = 0, l = catalogs.models.length; i < l; i++){
      	if (catalogs.models[i].id == selectedCatalogID){
       		catalog = catalogs.models[i];
      		break;
       	}
      }
      

      which does work as expected, but isn't as clean as using backbone's collection.get();

        Attachments

          Activity

            People

            • Assignee:
              shossain Shak Hossain (Inactive)
              Reporter:
              jmoretti Joe Moretti
            • Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Git Integration