ember.js - View doesn't update after pushing new POJO ember -


i've read ember works fine pojos in place of ember data, i'm giving shot, i'm having little trouble.

i'm creating app using nw.js , linvodb database. fetching db easy , works great:

// route/index import ember 'ember';  export default ember.route.extend({     model: function() {         var gui = require('nw.gui');         var linvodb = require('linvodb3');         linvodb.defaults.store = {db: require('medeadown')};         linvodb.dbpath = gui.app.datapath;         var file = new linvodb('file', {} );         var tags = new linvodb('tag', {});          var media = new promise(function(resolve, reject) {             var query = file.find().sort({ctime: -1}).live();              file.on('livequeryupdate', function() {                 resolve(query.res);             });         });          var tags = new promise(function(resolve, reject) {             var query = tags.find().sort({name: 1}).live();              tags.on('livequeryupdate', function() {                 resolve(query.res);             });         });          return ember.rsvp.hash({             media: media,             tags: tags         });     } }); 

i have simple event set create tag, save , push model:

//controllers/index actions: {     viewmedia: function(media) {         this.transitiontoroute('media', media)     },     addtag: function() {         var linvodb = require('linvodb3');         var gui = require('nw.gui');         linvodb.defaults.store = {db: require('medeadown')};         linvodb.dbpath = gui.app.datapath;          var tag = new linvodb('tag', {});         var tag = new tag();         tag.name = this.get('tagname');         tag.save();         this.get('model.tags').push(tag);     } } 

i can verify tag object being inserted correctly in the tag array in model, view isn't updating. i've read, that's cause i'm not using ember.object.

how suppose pojos or have use ember.objects? thanks.

ember provides it's own array implementation in ember.array/ember.mutablearray adds lot of nifty things, being observable in ember ecosystem. ember.mutablearray in particular (or rather ember.mutableenumerable if want go deep) has method called pushobject(obj) push object onto end of array. , notifies subscribers.

since ember nice enough add these regular arrays prototype make easy people going, should able this.get('model.tags').pushobject(tag); in code.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -