[Seaside] Use of onMouseOver: and onMouseOut: in Seaside 2.8x

Richard E. Flower rickf at ca-flower.com
Fri Nov 7 06:55:49 UTC 2008


On Nov 6, 2008, at 1:11 AM, Sebastian Sastre wrote:

>
> Hi Richard,
>
> that will be rendered as javascript so you can't expect a server  
> side halt for
> code that runs in DOM unless a callback is envolved. Unfortunately  
> there is not
> Firebug code halts yet to mimic our debugging style. I miss that when
> javascripting.
>
> You can use this to check in firebug's console if your code executes  
> under your
> condition:
>
> 	SUScript new
> 		add: (SULogger new log: 'The mouse is over!');
> 		add: (your javascript serius code here);
> 		yourself
>
> Usage of onClick, onMouseOver, etc are considered the "vile way" to  
> do it.
> Instead prefer observe(). Details here:
> http://www.prototypejs.org/api/event/observe

Sebastian-

I don't suppose you've got an example using the above mentioned  
observe() code in Prototype
do you?  Is this what is used by Scriptaculous' SUElement?  I saw a  
reference to 'observe'
in there but wasn't sure.. I've just spent the last hour or so looking  
thru the old email
archives for this list and saw some tidbits but no concrete  
examples..  I also looked at the test
code for Scriptaculous but nothing similar to what I want to do, which  
is to change the css for
an id when the mouse goes over the row in a table...

I saw a reference in an email you wrote this past August talking about  
using :

========================
> From Seaside you access that with anElement>>on: anEventString do:
aHandlerObject
With prototype you can even use your own custom events like this:  
anElement
fire: 'mouse:enter'
========================

However, I'm not sure about the context in which to use the above..   
An example would
be great!

Currently my row rendering code looks something like :

renderRowNumber: index item: row on: html

	html tableRow id: 'row' , index asString;
		class: (self classForRowNumber: index);
		script: (self componentScriptOn: html);
		 onClick: (html evaluator
			callback: [:aScript | self adjustRowColorsUsingIndex: index  
onScript: aScript];
			 return: false);
		with: [columns
				do: [:ea | self
						renderColumn: ea
						row: row
						on: html]]

componentScriptOn: html

	^(Scriptaculous.SUScript new
		add: (Scriptaculous.SUEvent new
			observe: html scriptaculous document
			on: 'mouseover'
			do: (Scriptaculous.SULogger new log: 'The mouse is over!')
			); yourself;
	yourself).

====================================================
When I execute this with Firefox (and Firebug) I get the following  
error in the console window:

Event.observe is not a function
   onLoad()
   onLoad(load)



More information about the seaside mailing list