[Seaside] Re: I would like to attach an onClick event according to

Boris Popov, DeepCove Labs boris at deepcovelabs.com
Fri Feb 4 18:33:10 UTC 2011


renderContentOn: html

	| onclick |
	onclick := html javascript return: ((Javascript.JSStream new)
						nextPutAll: 'confirm';
						argument: (html jQuery
this attributeAt: 'href')).
	"Install on all anchors within a div"
	(html div)
		id: #external_links;
		script: ((html jQuery this)
					find: 'a';
					onClick: onclick);
		with: 
				[(html anchor)
					url: 'http://google.com';
					with: 'Google'].
	"Install on all anchors with rel=external"
	html div with: 
			[(html anchor)
				relationship: 'external';
				url: 'http://yahoo.com';
				with: 'Yahoo'].
	html document addLoadScript: ((html jQuery: 'a[rel="external"]')
onClick: onclick)

-----Original Message-----
From: seaside-bounces at lists.squeakfoundation.org
[mailto:seaside-bounces at lists.squeakfoundation.org] On Behalf Of Fritz
Schenk
Sent: Friday, February 04, 2011 12:42 PM
To: seaside at lists.squeakfoundation.org
Subject: [Seaside] Re: I would like to attach an onClick event according
to

Robert, even with the mess I made of the quotes, your code does not
work.
I suspect that the way Seaside handles quote is incorrect (see the
'generated source' below).
<your code>
renderContentOn: html 
	
"From Robert Sirois with id corrections and at 'You are'..."
1 to: 5 do: [:x |
html div
id: 'external_links';
with: [
html anchor
callback: [ x inspect ];
with: x
].
].

1 to: 5 do: [:x |
html div
id: 'external_links';
with: 'just some content'
].

html button
onClick: ((html jQuery expression: '#external_links a') onClick: 'return
confirm("You are going to visit: "+ this.href)');
with: 'Attach Click'.
</your code>
<generated source>
<div id="external_links">
  <a href="/whatever?_s=LG3lfxc-9JRlLsd5&_k=IrWB5OCYShO7CscD&6">1</a>
</div>
<div id="external_links">
  <a href="/whatever?_s=LG3lfxc-9JRlLsd5&_k=IrWB5OCYShO7CscD&7">2</a>
</div>
<div id="external_links">
  <a href="/whatever?_s=LG3lfxc-9JRlLsd5&_k=IrWB5OCYShO7CscD&8">3</a>
</div>
<div id="external_links">
  <a href="/whatever?_s=LG3lfxc-9JRlLsd5&_k=IrWB5OCYShO7CscD&9">4</a>
</div>
<div id="external_links">
  <a href="/whatever?_s=LG3lfxc-9JRlLsd5&_k=IrWB5OCYShO7CscD&10">5</a>
</div>
<div id="external_links">just some content</div> <div
id="external_links">just some content</div> <div
id="external_links">just some content</div> <div
id="external_links">just some content</div> <div
id="external_links">just some content</div> <button
onclick="$("#external_links a").click(function(){return confirm("You are
going to visit: "+ this.href)})" type="submit" class="submit">Attach
Click</button> </generated source>

Note the strange way that it has translate quotes - the JavaScript
interpreter (or compiler) has trouble with the double quotes

The correct code in JavaScript is in http://jsbin.com/imuka5/2

The code I want from the IBM article has the following expression:
<code>
$('#external_links a').click(function() {
    return confirm('You are going to visit: ' + this.href); }); </code>

_______________________________________________
seaside mailing list
seaside at lists.squeakfoundation.org
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


More information about the seaside mailing list