Created
June 11, 2015 15:13
-
-
Save jwalton512/5d43546f27ca59bab449 to your computer and use it in GitHub Desktop.
learning vue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var track = require('./track'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Vue = require('vue') | |
var trackStore = require('./trackStore'); | |
var vm = new Vue({ | |
el: '#admin-track', | |
data: { | |
storeData: trackStore.data, | |
tracks : trackStore.data.tracks, // doesn't receive updates, have to use $watch | |
}, | |
ready: function () { | |
this.$watch('storeData.tracks', function() { | |
this.tracks = this.storeData.tracks; | |
}) | |
} | |
}); | |
export default vm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Vue = require('vue').use(require('vue-resource')); | |
var trackStore = { | |
data: { | |
tracks: [], | |
}, | |
fetchAll: function () { | |
var self = this; | |
Vue.http.get('/api/admin/tracks', function(tracks) { | |
self.data.tracks = tracks; | |
}) | |
} | |
} | |
trackStore.fetchAll(); | |
export default trackStore; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment