I'm still trying to get to understand how Javascript is wrapped in Seaside, say I have the following query:
(html jQuery: '#myId') hasClass: 'myClass'
How do I get a true or a false out of this? For example in my case I'd love to be able to do:
html anchor
onClick:
(((html jQuery: '#myId')
hasClass: 'myClass')
ifTrue: [doSomething开发者_如何学Go]
ifFalse: [doSomethingElse]);
with: 'Magic Stuff!'
What's the seaside way of doing this?
Thanks!
Depends where you want to perform the decision on the client or on the server?
Decide and Perform Action on Client
You can use
((html jQuery: '#myId') hasClass: 'myClass')
then: aTrueExpression
else: aFalseExpression
where aTrueExpression' and
aFalseExpression' are other (jQuery) JavaScript expressions.
Decide and Perform Action on Server
You serialize the result of your expression into an AJAX callback and perform the action on the Smalltalk side:
html jQuery ajax
callback: [ :value |
value = 'true'
ifTrue: [ " true block " ]
ifFalse: [ " false block " ] ]
value: ((html jQuery: '#myId') hasClass: 'myClass')
精彩评论