[Seaside] calling a JS function

Boris Popov, DeepCove Labs boris at deepcovelabs.com
Wed Sep 7 20:28:40 UTC 2011


Also, keep in mind that often times you don't need to do #asJavascript yourself, for example you can pass the below dictionary as an argument to a function call and let the framework do its thing for you. The key here is that JSON by definition is an interchange format expressed as a subset of JavaScript, and when you're trying to create a snippet that includes a reference to an object, you no longer have valid JSON, but still have perfectly valid JavaScript.

-Boris

-----Original Message-----
From: seaside-bounces at lists.squeakfoundation.org [mailto:seaside-bounces at lists.squeakfoundation.org] On Behalf Of Boris Popov, DeepCove Labs
Sent: Wednesday, September 07, 2011 4:19 PM
To: Seaside - general discussion
Subject: RE: [Seaside] calling a JS function

Milan,

((Dictionary new)
  at: 'custom' put: (JSStream on: 'doSomething');
  yourself) asJavascript

'{"custom":doSomething}'

HTH,

-Boris


-----Original Message-----
From: seaside-bounces at lists.squeakfoundation.org [mailto:seaside-bounces at lists.squeakfoundation.org] On Behalf Of Milan Mimica
Sent: Wednesday, September 07, 2011 4:15 PM
To: Seaside - general discussion
Subject: Re: [Seaside] calling a JS function

I get an error: WAError: Override #jsonOn: to make the receiver serializeable as JSON (JSStream on: 'doSomething') returns a JSStream object who doesn't understand asJson.


On 7 September 2011 21:55, Johan Brichau <johan at inceptive.be> wrote:
> Try this:
>
> (Dictionary newFrom: {'custom' -> (JSStream on: 'doSomething')}) asJson.
>
> I would want to know if there is a better way.
>
> On 07 Sep 2011, at 21:31, Milan Mimica wrote:
>
>> I need to pass s JS function to some jQuery widget. I don't want to 
>> inline it, but instead have it separate in a file.
>>
>> The problem is:
>> (Dictionary newFrom: {'custom' -> #doSomething}) asJson.
>> produces:
>> {"custom":"doSomething"}
>> while I need:
>> {"custom":doSomething}           (without quotas)
>>
>>
>>
>> --
>> Milan Mimica
>> http://sparklet.sf.net
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
Milan Mimica
http://sparklet.sf.net
_______________________________________________
seaside mailing list
seaside at lists.squeakfoundation.org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
seaside at lists.squeakfoundation.org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


More information about the seaside mailing list