framework7

Open full view…

Get virtual list data from external JSON?

realn3rd
Thu, 10 Aug 2017 19:39:26 GMT

What is the best pratice, to get the data of a virtual list from an external json file? The examples only showing the procedure with embedded data.

realn3rd
Sat, 26 Aug 2017 10:21:28 GMT

Console: ReferenceError: StatusBar is not defined[Weitere Informationen] deviceready.js:16:3 Error: Module cordova-plugin-admobpro.AdMob does not exist. cordova.js:1297:15 ReferenceError: AdMob is not defined[Weitere Informationen] bwiki-app.js:55:1 Channel not fired: onPluginsReady localhost:3000:314:13 Channel not fired: onCordovaReady localhost:3000:314:13

proyectodo
Mon, 28 Aug 2017 12:34:06 GMT

But you're using my example. You need to change to your needs. Is not the same JSON.

proyectodo
Mon, 28 Aug 2017 12:39:29 GMT

Check this example, you need to add *["posts"]* to access the data. Use this tool http://jsonviewer.stack.hu/ to know the estructure of the JSON. --- myApp.onPageInit('noticias', function (page) { myApp.showPreloader('Cargando notas…'); $$.getJSON(“public-api.wordpress.com/…/?number=1&callback=?”, function(jsondata){ myApp.hidePreloader(); var old=jsondata; var objnoti=[]; for(var i=0;i<old.length;i++){ var tit=old["posts"][i][“title”]; var con=old["posts"][i][“content”]; var url=old["posts"][i][“URL”]; var t={}; var z={}; t.id=i+1; t.titulo=tit; t.contenido=con; t.blog=url; objnoti.push(t); } Template7.data['url:test.html'] = objnoti; ---

realn3rd
Thu, 31 Aug 2017 11:57:05 GMT

Now the console says: TypeError: r.pageContent[0] is undefined It says line 807, which contains the following: var myList = myApp.virtualList('.virtual-list.list-block.cards-list.lista-noticias' , {

proyectodo
Thu, 31 Aug 2017 12:48:08 GMT

I think it's the classes you added to the vitual list. You only have two classes --- <div class=“virtual-list list-block”> <!— keep it empty —> </div> --- Change this --- var myList = myApp.virtualList('.virtual-list.list-block.cards-list.lista-noticias' , { --- to this --- var myList = myApp.virtualList('.virtual-list.list-block' , { ---

realn3rd
Thu, 31 Aug 2017 14:08:39 GMT

I won't work for me. The console show now no error. Can you try to get it work on jsfiddle.net?

realn3rd
Sat, 02 Sep 2017 15:55:04 GMT

Any idea?

realn3rd
Wed, 06 Sep 2017 19:27:51 GMT

I put the files into a zip-file and uploaded it to dropbox. https://www.dropbox.com/s/or8zgyvlbfpgftv/www.zip?dl=0

proyectodo
Thu, 07 Sep 2017 20:09:22 GMT

Two changes. In index.html, head section . This line have conflict. Commented, eliminate or changed it. ---<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *"> --- and in js file change line 64 to this --- Template7.data['url:about.html'] = objnoti; --- With this changes works,. but doesn't shows othign,. Thats because there some error in the *for* on js file. I think. Check the code and use console.log to see the errors.

realn3rd
Thu, 07 Sep 2017 20:57:13 GMT

The JSON-File is beeing loaded but it won't show up :/

realn3rd
Tue, 12 Sep 2017 17:30:57 GMT

Did it work for you?

realn3rd
Sun, 17 Sep 2017 20:07:46 GMT

No Idea? :(

proyectodo
Tue, 19 Sep 2017 12:57:54 GMT

Sorry,. but I don't have time to test,. But if there's no error in the console,. you need to check the *javascript for* statement, maybe there's an error in the route the data. This line maybe has an error. --- var tit=old["posts"][i][“title”]; ---

realn3rd
Wed, 20 Sep 2017 19:22:33 GMT

Do you have time for a test in a few days oder weeks?

proyectodo
Thu, 21 Sep 2017 12:03:27 GMT

Maybe the next.

realn3rd
Thu, 21 Sep 2017 15:50:36 GMT

Ok

realn3rd
Sat, 28 Oct 2017 11:14:35 GMT

hey, do you have time for a test?

proyectodo
Sat, 28 Oct 2017 20:23:05 GMT

Sorry, i can't make it work.

realn3rd
Sat, 28 Oct 2017 21:32:13 GMT

ok :/

proyectodo
Tue, 31 Oct 2017 13:24:21 GMT

Here are the files changed by me: https://we.tl/KMSLhx1Ojs If you check the console, you'll see there's *[]* thats is empty. that's why nothing is shown. The error is in the JS code, i'm sure of that. --- $$.getJSON("https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/posts/?number=1&callback=?", function(jsondata){ myApp.hidePreloader(); var old = jsondata; var objnoti=[]; for(var i=0;i<old.length;i++){ var tit=old[i]["title"]; var t={}; t.titulo=tit; objnoti.push(t); } Template7.data['url:about.html'] = objnoti; ---- I hope you can make it work.

next