jeudi 30 janvier 2020

Ember.js combining two objects from datastore to a string

I have gathered 1 string from 2 different places in the datastore, an URL and a nickname, what I want to do is combine these two so I can "pre-select" in my dropdown. The problem is, if I check the value within the "declaration of the variables" then I get the text result alerted, but if I alert afterwards when I'm trying to combine the two strings, I get [Object object], [Object object] instead. And for some reason I get the Object Objects first, and then the URL and then the nickname, which isn't even the correct order..? The code looks like this:

preSelect: function (orgSiteId, orgId) {
    'use strict';
    var url = this.get('store').find('orgSite', orgSiteId).then(function (orgSites) {
        alert(orgSites.get('url'));
        return orgSites.get('url');
    }.bind(this));
    var nickname = this.get('store').find('org', orgId).then(function (orgs) {
        alert(orgs.get('nickname'));
        return orgs.get('nickname');
    }.bind(this));

    this.set('testFillSelect', nickname + ', ' + url);
    alert(this.get('testFillSelect'));
},

Is this a situation where I want to use computed properties or observer? I'm new to Ember.js and this feels like it's supposed to be simple.




Aucun commentaire:

Enregistrer un commentaire