javascript - Ember.js Save Up and Down Vote to the Data -


i used jsfiddle (http://jsfiddle.net/chopper/ggggd/22/) stackoverflow question (how handle votes in ember.js?) add , down voting ember site. in fiddle, data lives inside app.js, have no backed database.

the , down voting works, not save data, resets on page refresh. how save change when upvotes appreciated!

controller

app.themecontroller = ember.objectcontroller.extend({ actions: {     voteup: function () {         console.log("voting up");            this.set('votes', this.get('votes') + 1);      },     votedown: function () {         console.log("voting down");         this.set('votes', this.get('votes') - 1);     } } }); 

data

app.themes = [ { id: 1, title: 'decode', price: '$0', free: true, description: 'a minimal, modern theme, designed mobile first , responsive, decode built ghost , uses ghost\'s innovative features present beautiful , clean blog.', columns: 1, popular: true, purchaselink:'https://github.com/scottsmith95/decode-for-ghost', demolink:'http://decode-ghost-demo.scotthsmith.com', image: 'images/decode.jpg', votes: 0 }, .... 

thanks, david b

form ember.js guide.

you need call save() on objects, this.

votedown: function () {         console.log("voting down");         this.set('votes', this.get('votes') - 1);         this.save();     } 

edit: however, if used jsfiddle mentioned, not have data persistence related code. method not work. ember-data.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -