Note that there are some explanatory texts on larger screens.

plurals
  1. POpassing parameter in jquery auto complete
    primarykey
    data
    text
    <p>I'm trying to implement auto complete in my rails application. I'm trying to pass ruby parameter via source of the jquery. Here is what I'm trying to do.</p> <pre><code>$( "#text" ).autocomplete({ appendTo: "#searchwrapper1", source: h_url+"product_details/menu_search_auto/" + &lt;%= "'#{params[:deptid]}'" %&gt; , open:function() { $(".ui-autocomplete").mCustomScrollbar1({ set_width : false, set_height : false, horizontalScroll : false, scrollInertia : 550, scrollEasing : "easeOutCirc", mouseWheel : "auto", autoDraggerLength : true, scrollButtons : { enable : false, scrollType : "continuous", scrollSpeed : 20, scrollAmount : 40 }, } </code></pre> <p>Here is my route.rb file</p> <pre><code>match "/product_details/menu_search_auto/:deptid"=&gt;'product_details#menu_search_auto' </code></pre> <p>and controller part is:</p> <pre><code>def menu_search_auto list=[] if(params[:deptid].to_s == 'all') b1=test4.where("name LIKE ?","#{params[:term]}%") else case params[:deptid].to_i when 1 b1=test1.where("name LIKE ?","#{params[:term]}%") when 2 b1=test2.where("name LIKE ?","#{params[:term]}%") when 3 b1=test3.where("name LIKE ?","#{params[:term]}%") else end end b1.each do |b1| list &lt;&lt; {"label"=&gt;b1.name, "value"=&gt;b1.name, "id"=&gt;b1.id} end respond_to do |format| format.json{render :json=&gt;list.to_json, :layout=&gt;false} end end </code></pre> <p>But neither I'm able to pass the parameter nor I'm getting any error.</p> <p>Please suggest me where I'm going wrong??</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload