I am building a task management application in ROR. I am new to ROR and
learning it. While adding tasks, I need to select a projects drop down
list and the team members of that project will be shown as drop down. I
am using ajax for it. But I see that in the response data I am getting
the complete htmls with header (not only the drop down htmls). Please
help.

============_form.html.erb=============================

<%= select( "project", "id", { "abc" => "1", "xyz" =>
"2"}),:onchange=>"getComboA(this)"%>

function getComboA(sel)
{
var value = sel.options[sel.selectedIndex].value;
$.get("/users_projects?id="+value,function(data) {
alert(data);
$("#user_1").html("<label>User Details</label>"+data);
});
}

=============Task Controller=================

def users_projects
@projs = ProjectsUser.find_all_by_project_id(params[:id])
@users=[]
@projs.each do |pro|
@users<<User.find(pro.user_id)
end
end

===========users_projects.html.erb================

<%if !@users.blank?%>
<%=select_tag :user_id,options_from_collection_for_select(@users,
"id", "email")%>
<%end%>

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Ruby rails at Oct 2, 2012 at 10:01 am
    When I am alerting data I am getting the below htmls inserting before
    select tag of team members
    <html>
    <head>
    <title>TaskManagement</title>
    <link href="/assets/style.css" media="screen" rel="stylesheet"
    type="text/css" />
    <link href="/assets/validationEngine.jquery" media="screen"
    rel="stylesheet" type="text/css" />
    <script src="/assets/highcharts.js" type="text/javascript"></script>
    <script type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="
    " rel="nofollow">http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>

    <script src="/assets/application.js" type="text/javascript"></script>
    <script src="/assets/jquery.validationEngine"
    type="text/javascript"></script>
    <script src="/assets/jquery.validationEngine-en"
    type="text/javascript"></script>
    <script src="/assets/rails.validations" type="text/javascript"></script>
    <script src="/assets/rails.validations.custom"
    type="text/javascript"></script>
    </head>
    <body>

    <select id="user_id" name="user_id"><option
    value="4">nithins@gmail.com</option></select>


    </body>
    </html>

    ruby rails wrote in post #1078321:
    I am building a task management application in ROR. I am new to ROR and
    learning it. While adding tasks, I need to select a projects drop down
    list and the team members of that project will be shown as drop down. I
    am using ajax for it. But I see that in the response data I am getting
    the complete htmls with header (not only the drop down htmls). Please
    help.

    ============_form.html.erb=============================

    <%= select( "project", "id", { "abc" => "1", "xyz" =>
    "2"}),:onchange=>"getComboA(this)"%>

    function getComboA(sel)
    {
    var value = sel.options[sel.selectedIndex].value;
    $.get("/users_projects?id="+value,function(data) {
    alert(data);
    $("#user_1").html("<label>User Details</label>"+data);
    });
    }

    =============Task Controller=================

    def users_projects
    @projs = ProjectsUser.find_all_by_project_id(params[:id])
    @users=[]
    @projs.each do |pro|
    @users<<User.find(pro.user_id)
    end
    end

    ===========users_projects.html.erb================

    <%if !@users.blank?%>
    <%=select_tag :user_id,options_from_collection_for_select(@users,
    "id", "email")%>
    <%end%>
    --
    Posted via http://www.ruby-forum.com/.

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Walter Lee Davis at Oct 2, 2012 at 2:18 pm

    On Oct 2, 2012, at 5:58 AM, ruby rails wrote:

    I am building a task management application in ROR. I am new to ROR and
    learning it. While adding tasks, I need to select a projects drop down
    list and the team members of that project will be shown as drop down. I
    am using ajax for it. But I see that in the response data I am getting
    the complete htmls with header (not only the drop down htmls). Please
    help.
    You need to specify to render without the outer layout in your controller:

    render :layout => false

    Walter

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedOct 2, '12 at 9:58a
activeOct 2, '12 at 2:18p
posts3
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Ruby rails: 2 posts Walter Lee Davis: 1 post

People

Translate

site design / logo © 2021 Grokbase