- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Este código esta atualizando a lista de dados puxadas do banco de dados apenas quando o botão sync e acionado gostaria que ele atualizasse assim que o app abrir.
document.addEventListener("deviceready",onDeviceReady,true); function onDeviceReady(){ var vm = new Vue({ el: '#app', data:{ noticias: [] }, methods:{ sync:function(){ $.ajax({ dataType: 'json', url: 'http://example.com/read.php', success:function(dados){ localStorage.setItem('noticias',JSON.stringify(dados)); vm.setNoticias(); }, error:function(){ alert("ocorreu um erro durante a conexão com o servidor!"); } }); }, setNoticias:function(){ this.noticias = JSON.parse(localStorage.getItem('noticias')); console.log(this.noticias); } }, ready:function(){ this.setNoticias(); } }) }
- Tags:
- HTML5
- Intel® XDK
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First off, it looks like your sync function is defined on its own. Do you connect this 'sync button' to the sync function somewhere else - or does this define that button? What I suggest is in the ready function you defined, you call the sync function from up above. Much like you call the setNoticias function, this way once the device is ready, you fire the function that pulls from the database and then updates.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page