When autocomplete sends a query string, it contains the term parameter. See here:
Started GET "/nodes/autocomplete_user_first_name?term=Mi" for 127.0.0.1 Processing by NodesController#autocomplete_user_first_name as JSON Parameters: {"term"=>"Mi"}
I need to add a parameter to the value available in my view in order to get something like this, using node as the parameter and 27 as the value:
Started GET "/nodes/autocomplete_user_first_name?term=Mi&node=27" Processing by NodesController#autocomplete_user_first_name as JSON Parameters: {"term"=>"Mi", "node" => 27}
If I need to add a javascript file through jQuery, please tell me where it should go. I am new to js / jQuery, but I understand that. Thank!
EDIT
The reason I need the node parameter is because I need to limit the scope based on its value.
def get_autocomplete_items(parameters) items = active_record_get_autocomplete_items(parameters) items = items.where(:id => current_user.family_tree.memberships.pluck(:user_id)) .where.not(:full_name => node.user_tags.pluck(:name)) end
javascript jquery jquery-ui ruby-on-rails autocomplete
mike0416 Nov 04 '15 at 20:37 2015-11-04 20:37
source share