In my Rails 3 ajax scaffolding I have a hook on ajax:success which takes any code defined in a data-loaded attribute of the calling entity (a, form etc) and executes it using jQuery.globalEval. I want to access a local variable in the hook, for example the returned data, but if I use...
alert( data )
...in the loaded param it gives me a unreferenced variable error even though that parameter is in the hook params.
Any idea how to use the data variable without changing the scaffold? It wouldn't be hard to change the scaffold but it'd be nice not to have to!
An example of what I'm talking about in it's simplest form:
function testMe( data )
{
jQuery.globalEval( 'alert( data );' );
}
This code is telling me data is not defined, how do I pass data to the globalEval is my question.