[Sugar-devel] How do you save stuff in web activities?

Lionel Laské lionel at olpc-france.org
Sun Mar 23 06:02:29 EDT 2014


Hi Sam,

You could find an example in my LOLActivity [1].
Load is call here [2].
Save is call each time the board change [3].
The Load/Save process is here [4].

Hope it could help.

Best regards from France.

           Lionel.


[1] http://activities.sugarlabs.org/en/sugar/addon/4717
[2] https://github.com/llaske/LOLActivity/blob/master/js/activity.js#L28
[3] https://github.com/llaske/LOLActivity/blob/master/js/app.js#L138
[4] https://github.com/llaske/LOLActivity/blob/master/js/app.js#L183

2014-03-22 8:36 GMT+01:00 <sugar-devel-request at lists.sugarlabs.org>:
>
>
> Message: 1
> Date: Sat, 22 Mar 2014 15:34:33 +1100
> From: Sam Parkinson <sam.parkinson3 at gmail.com>
> To: Manuel Qui?ones <manuq at laptop.org>, Sugar-dev Devel
>         <sugar-devel at lists.sugarlabs.org>
> Subject: [Sugar-devel] How do you save stuff in web activities?
> Message-ID:
>         <CACVKbrVomF2ayh1bUfCXeDSxzShjSxy3dag3Z0RES=
> 5DDoiHkg at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> Hi,
>
> I'm just wondering, does anyone have any code snippets for saving on web
> activities?
>
> I'm trying to make a web activity and am having some issues. Here is my
> save+load code: [CoffeeScript]
>
> activity.setup()
> datastoreObject = activity.getDatastoreObject()
> onLoaded = (error, metadata, data) ->
>   alert data
>   obj = JSON.parse data
>   console.log obj
>   container.html obj.html
>   $('section').each (x, ele) ->
>     scribe_slide_setup ele
>   undefined
> datastoreObject.loadAsText onLoaded
>
> activity.write = ->
>   obj =
>     html: container.html()
>   jsonData = JSON.stringify obj
>   datastoreObject.setDataAsText jsonData
>   datastoreObject.save()
>
> Neither methods end up getting called. I'm using 0.100.0.
>
> Thanks,
> Sam
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140323/c62fa265/attachment.html>


More information about the Sugar-devel mailing list