[Seaside] a problem with a javascript statement
Johan Brichau
johan at inceptive.be
Fri Apr 8 15:03:48 UTC 2011
Hi Esteban,
This should work right out of the box:
(JSStream on: '$(this).val().length == 0')
then: (html javascript return: false)
else: (html javascript return: true)
although you might want to shrink that to: (html javascript return: (JSStream on: '$(this).val().length != 0'))
And, indeed, there are some gaps in the javascript DSL. Although I prefer to push as much javascript out to separate files, instead of using strings or the DSL itself.
We have nevertheless implemented some modest extensions for our own purpose, but if there is interest to seeing the DSL expanded, I would happily contribute them.
For '==' in JS, just add this method:
JSObject>>equals: anObject
self addDecoration: (JSBinary new operator: '=='; statement: anObject)
Also mind that the #then:else: only accepts a single javascript statement in each branch.
I think the DSL is good to combine JS statements that you really need to generate (such as the jQuery ajax callbacks). For everything else, I use JSStream or external files.
cheers
Johan
On 08 Apr 2011, at 16:39, Esteban Lorenzano wrote:
> Hi,
> I want to write this code:
>
> function() {
> if ($(this).val().length == 0) {
> return false;
> }
> return true;
> }
>
> but I want to use seaside javascript dsl to do that...
> I suppose the code should be something like this:
>
> (((html javascript return: false)
> condition: (html jQuery this find: 'input'; value; access: 'length'; equals: 0)),
> (html javascript return: true))
> asFunction
>
> the problem is: it does not exists an "#equals:" message (not a greater:, etc. )
>
> so, I wonder how you do this using the DSL... is there a way? or I need to add that protocol?
>
> thanks,
> Esteban
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
More information about the seaside
mailing list