Lee Thompson wrote:
Hi,
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 ******* <script type="text/javascript"> function javascript_functionA(items){ //do things with items } </script> <% form_remote_tag :complete => "javascript_functionA('#{myArray}'), :url => {:action => :controller_functionA} %>
******** 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