[Seaside] Jquery select then hide

Johan Brichau johan at inceptive.be
Sun May 3 08:58:23 UTC 2015


Generating pieces of Javascript code is only appropriate when they _need_ to be generated. For example, when you need to generate a Seaside-JQuery callback inside a javascript, only Seaside can generate the right url for the callback and injecting it into a piece of Javascript code is easily done with Seaside’s Javascript-generation logic.

html button
	bePush;
	onClick: (html jQuery ajax callback:[ self iWasClicked ]);
	with: ‘Click me!'

Seaside allows you to generate Javascript code, just like it allows you to generate html, but that should not tempt you to generate anything more than what needs to be generated. There is a conceptual difference between generating html (which is a declarative output) and Javascript code (which is procedural output), that makes it harder to understand. However, generating simple things around callbacks can be easy:

html button
	bePush;
	onClick: (html jQuery this) hide, (html jQuery ajax callback:[ self iWasClicked ]),(html jQuery this) show, html javascript return: false;
	with: ‘Click me!'

If you need pieces of javascript code that can be hand-written, then just write them down in a separate file and include it on the page. 

updateRoot:
	super updateRoot: aRoot.
	aRoot javascript resourceUrl: ‘myapp.js’

If that is too much for what you want to do, there is always JSStream:

html button
	bePush;
	onClick: (JSStream on: ‘$(“#foobar”).html(“Someone clicked me”); return false;');
	with: ‘Click me!’

cheers
Johan

ps: The examples above are just to demonstrate code options, they do not show any useful interaction.

> On 02 May 2015, at 11:46, Hilaire <hilaire at drgeo.eu> wrote:
> 
> Ok.
> This way of definining Javascript snippet code is very Smalltalkish :)
> 
> I am wondering what is the pros and cons compared to just pure
> javascript code integrated in a page as we do it for css descriptions.
> Easier to debug? To protoype? But slower?
> Anyway both options are there so it is nice.
> 
> Hilaire
> 
> Le 01/05/2015 14:11, Johan Brichau a écrit :
>> You’re right. JSObject>>equals: is an extension that is not in the standard Seaside package.
>> I’ll add it, but in the meantime, here’s the implementation:
>> 
>> JSObject>>equals: anObject 
>> 	"Combine the receiver and anObject with a logical AND."
>> 	
>> 	self addDecoration: (JSBinary new operator: '=='; statement: anObject)
> 
> 
> -- 
> Dr. Geo - http://drgeo.eu
> iStoa - http://istoa.drgeo.eu
> 
> 
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside



More information about the seaside mailing list