Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

how to pass a local variable array to a function

hello Appery team,
I have read a lot of documents and past post, but cannot figure out how to pass an array from REST to a FUNCTION.
I ́m using a third party script to schedule events "calendar event".
it uses in line data to show next events, like this:

var eventsInline = [{"date": "1388318400000", "type": "training", "title": "super class", "description": "learn to teach", "url": "http://www.event1.com/"}];
$(cal).eventCalendar({
jsonData: eventsInline
});

using this notation I get this result :

Image

I have save this same array in DB, and saved in a collection like this:

Image

and linked to a local variable and then pass it to the function like this:

Image

and then :

Image

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

how to pass a local variable array to a function

doesn ́t show anything as before (passing the inline Array). What I ́m doing wrong? Can you help me to get this done?

Thanks in advance!

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

how to pass a local variable array to a function

Hi Alex,

Please try to debug your code first :: http://docs.appery.io/documentation/d...

  • what is the value of a localStorage after you have made the mapping? Try to use brake points in code with console.log() or alert().

    Also notice that you are storing data in your collection as a string, it should be the array.
    :: http://docs.appery.io/documentation/b...

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

how to pass a local variable array to a function

Hello, Illya, I have tried to debug this...after doing mapping, I have this alert , as you can see in the code:

Image

which is the same array I ́m manually passig to the function.

I have tried "string" "array" and "pointer" in the DB with no success...

any other suggestion?

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

how to pass a local variable array to a function

as you can see,,this is an array of strings...wich is OK...(is the same array that works if is pass to the function manually).

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

how to pass a local variable array to a function

You are getting the JSON string, and you need to pass the array.
Use JSON.parse to get the array from the JSON string:
pre
var array = JSON.parse(localStorage.getItem("_eventoss"));
/pre

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

how to pass a local variable array to a function

Thanks Illya,
I add this line, and now is working!

Dupdroid
Posts: 0
Joined: Sat Mar 30, 2013 9:07 pm

how to pass a local variable array to a function

Hi Alex,

I'm also trying to use eventCalendar in my project but I can't get it to work. What steps did you follow to get it working in your project?

I have uploaded the javascript and css files and added a div to my page with the following code on load:

$("#eventCalendarInline").eventCalendar({
jsonData: eventsInline
});

But when I run it I get the following error:

TypeError: flags.wrap.find is not a function

Alex GG
Posts: 0
Joined: Thu Nov 14, 2013 11:11 pm

how to pass a local variable array to a function

Hello Chis!
1, add two CSS files ( /* Theme CSS / and /= CORE CSS */ you can find both in the zip file)

  1. add JS file jquery.eventCalendar.js

  2. add the div
    4 if you are going to use the array eventsInline use this:
    var eventsInline = [{"date": "1388318400000", "type": "training", "title": "super class", "description": "learn to teach", "url": "http://www.event1.com/"}];
    $(cal).eventCalendar({
    jsonData: eventsInline
    });

    but, if you want to pass the array from rest, link the array to local Storage, and in the success event put this JS:

    var array = JSON.parse(localStorage.getItem("_eventoss"));
    $(cal).eventCalendar({
    jsonData: array,
    .
    .
    .

    But as far as I can see with the type of error that you get, I almost sure that the problem is your CSS files, or the Custom JavaScript.

    this is the link to download the zip file:

    http://code.google.com/p/jquery-event...=

    and use this files:

    jquery.eventCalendar (JS)
    eventCalendar and eventCalendar_theme (CSS)

    hope this helps..

Nikita
Posts: 0
Joined: Fri Feb 28, 2014 4:02 pm

how to pass a local variable array to a function

Hi,

Please add eventCalendar.js as a custom JS, add HTML component to the page, click "edit HTML" and add to it < div id="cal_id" < .
Then, for example, on pageShow event, invoke the code, as it's stated here: http://www.vissit.com/projects/eventC...

Return to “Issues”