calling a JS function

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

calling a JS function

mmimica
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
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: calling a JS function

Johan Brichau-2
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
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: calling a JS function

mmimica
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 <[hidden email]> 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
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
Milan Mimica
http://sparklet.sf.net
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: calling a JS function

Boris Popov, DeepCove Labs (SNN)
Milan,

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

'{"custom":doSomething}'

HTH,

-Boris


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] 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 <[hidden email]> 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
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
Milan Mimica
http://sparklet.sf.net
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: calling a JS function

Boris Popov, DeepCove Labs (SNN)
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: [hidden email] [mailto:[hidden email]] 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: [hidden email] [mailto:[hidden email]] 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 <[hidden email]> 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
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



--
Milan Mimica
http://sparklet.sf.net
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: calling a JS function

mmimica
In reply to this post by Boris Popov, DeepCove Labs (SNN)
Thanks, sending asJavascript instead of asJson worked.

On 7 September 2011 22:18, Boris Popov, DeepCove Labs
<[hidden email]> wrote:

> Milan,
>
> ((Dictionary new)
>  at: 'custom' put: (JSStream on: 'doSomething');
>  yourself) asJavascript
>
> '{"custom":doSomething}'
>
> HTH,
>
> -Boris
>
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] 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 <[hidden email]> 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
>>> [hidden email]
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>> _______________________________________________
>> seaside mailing list
>> [hidden email]
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>
>
>
>
> --
> Milan Mimica
> http://sparklet.sf.net
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>



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