Hello friends, How can i get the _searchoutput.h tml.haml in my views/projects/_searchoutput.h tml.haml, using the controller projects_contro ller.erb accessed by my coffee script ajax search code and output it into tbody#search_ou tput in views/projects/index.html.haml for search output.?
My code in controllers/projects_contro ller.erb
heres my ajax. .
Heres is the code in views/projects/_searchoutput.h tml.haml
and here is my code in views/projects/index.html.haml
Note: Please don't use a filename.js.erb
Thank you and advance. . . :)
Please help me here, ,
My code in controllers/projects_contro ller.erb
Code:
class ProjectsController < ApplicationController
# GET /projects
# GET /projects.json
def index
@projects = Project.all
if !user_signed_in?
redirect_to "/users/sign_in"
else
if params[:search]
@projects = Project.search(params[:search]).order("updated_at ASC").page (params[:page])
# whats the codes here?????
else
@projects = Project.order("updated_at ASC").page (params[:page])
# whats the codes here?????
end
end
end
end
Code:
$("input#search").keyup ->
search = $(this).val()
$.ajax
url: "/projects?search=" + search + ".json"
type: "GET"
success: (searchoutput) ->
$("tbody#search_output").html searchoutput
console.log searchoutput
error: (request, status, error) ->
console.log request.responseText
Code:
= content_tag_for(:tr, @projects) do |project|
%td= project.title
%td= project.decription
%td.shrink
= project.addbyemail
%td.shrink2
= project.created_at.strftime("%m/%d/%Y")
%td.shrink
= link_to 'Show', project, :class => 'btn btn-mini'
%td.shrink
= link_to 'Edit', edit_project_path(project), :class => 'btn btn-primary btn-mini'
%td.shrink
= link_to 'Delete', project, :class => 'btn btn-danger deleterow btn-mini', remote: true
Code:
%span#msg
.alert-success.msgsuccess
%a.close.msgclose{:style => "color: rgb(0, 136, 204);"} ×
%strong.msgdisplay
%h2 List of Projects
%br/
%div{align: "center", style: "width:100%;"}
= form_tag projects_path, :id => 'search_form', :method => 'get' do
%table.tblsearch
%tr
%td.shrink
= submit_tag "Search", :name => nil, :class => 'btn btn-info '
%td= text_field_tag :search, params[:search], autofocus: true, :id => "search"
%br/
%table.table.table-bordered.table-striped.topmargin
%thead
%tr
%th Title
%th Description
%th Posted by
%th Date created
%th
%th
%th
%tbody#search_output
= render "projects/searchoutput"
%div.leftside.linkx
= link_to 'Add Project', new_project_path, :class => 'btn btn-primary '
%div.leftside.paginator
= paginate @projects
Thank you and advance. . . :)
Please help me here, ,
Comment