I’ve been looking around on the forums and tutorials but I still can’t
seem to make this work.
Here is what I am trying to do.
I have a view do a form_remote_tag with some variables. In the
controller I want to create an array, fill it with values, and when the
function returns I want to call a javascript function with this array.
currently this is what I have that doesn’t work
******** view *******
******** controller *******
class MyController < ApplicationController
def controller_functionA
myArray = [“so”, “many”, “exciting”, “things”]
end
end
I don’t know what parameters are valid for javascript_functionA(), but
it
may be expecting (‘value1’, ‘value2’, … ). Looks like ‘#{myArray}’ is
giving
just one parameter (‘value1’).
You may have to reference each array value by its indices.
******** controller *******
class MyController < ApplicationController
def controller_functionA
myArray = [“so”, “many”, “exciting”, “things”]
end
end
I don’t know what parameters are valid for javascript_functionA(), but
it
may be expecting (‘value1’, ‘value2’, … ). Looks like ‘#{myArray}’ is
giving
just one parameter (‘value1’).
You may have to reference each array value by its indices.
Long
Thanks for the response Long,
You might be right about that… but for now I actually get this error
undefined local variable or method `myArray’ for
#<#Class:0x409c9ec4:0x409c9e9c>
The array never makes it to the javascript_functionA
the MyController creates myArray, but the view has no idea about it.