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

Sam Parkinson sam.parkinson3 at gmail.com
Sun Mar 23 17:08:36 EDT 2014


The domReady! worked a charm :)


On Sun, Mar 23, 2014 at 9:19 PM, Daniel Narvaez <dwnarvaez at gmail.com> wrote:

> Does it work if you do it inside domReady like gtd? I don't remember if
> that's required by the API (probably not) but it might trigger a race
> condition anyway.
>
>
> On Sunday, 23 March 2014, Sam Parkinson <sam.parkinson3 at gmail.com> wrote:
>
>> Hi,
>>
>> I think this is an issue with the backend. I changed to using the
>> dictstore in my activity and it works a charm in chrome; it calls my loaded
>> callback. But on sugar it hangs with loading the data.
>> I have no idea what is wrong, since it works for get things done activity.
>>
>> Sam
>>
>>
>> On Sat, Mar 22, 2014 at 6:55 PM, Sam Parkinson <sam.parkinson3 at gmail.com>wrote:
>>
>>> Hi,
>>>
>>> I am just calling this form "define(function(require)". You can see the
>>> rest of the file here
>>> https://github.com/SAMdroid-apps/sugar-slides/blob/master/js/activity.coffee
>>>
>>> Thanks :)
>>>
>>>
>>> On Sat, Mar 22, 2014 at 6:36 PM, Daniel Narvaez <dwnarvaez at gmail.com>wrote:
>>>
>>>> Where are you calling this from? You should not need to setup()
>>>> manually.
>>>>
>>>>
>>>> On Saturday, 22 March 2014, Sam Parkinson <sam.parkinson3 at gmail.com>
>>>> wrote:
>>>>
>>>>> 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
>>>>>
>>>>
>>>>
>>>> --
>>>> Daniel Narvaez
>>>>
>>>>
>>>
>>
>
> --
> Daniel Narvaez
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20140324/3b69a1cb/attachment.html>


More information about the Sugar-devel mailing list