View Single Post
Old 11-08-2012, 04:58 PM   #7
psyang
Powerplay Quarterback
 
Join Date: Jan 2010
Exp:
Default

Something doesn't quite look right with the syntax in your code snippet.

First, the parameters you are passing into remoteFunction look like malformed json. You are missing {} around the property/value pairs.

Second, the params property value doesn't look quite right - the quotes aren't lining up properly.

Third, if you are using jQuery, you should use their built-in functions for getting the element value ($('#<element id>').val()). It's a bit cleaner, and will leverage jQuery's cross-browser support.

Maybe it should read something like:

Code:
<select onchange="${remoteFunction( {
				controller: 'aController',
				action: 'anAction',
				params: '\'obj.id=' + $('#element').val()+ '\'',
				update: 'anotherElement'
			})}"
Finally, that params value looks a little non-standard. As I've written it above, what will get passed in params is the following string (with the single quotes):

'obj.id=myElementValue'

where myElementValue is the value of the element. Is this correct?

I have a love-hate relationship with javascript, though more on the love side the last couple years. I like the way you can pass scope around like lisp closures, and the dynamic nature of the language is very useful at times. I wouldn't mind if it were more strongly typed, and had better IDE support, though. And a compiler to catch all the silly errors and typos would be nice too.
psyang is offline   Reply With Quote