Rails 3: How to “redirect_to” in Ajax call?


Replaced below redirect method

redirect_to(:controller => 'jobs', :action => 'index')

with this:

render :js => "window.location = '/jobs/index'"

and it works fine!

Else

Pass static url to link

= link_to ‘Set as application form’, “org_form_and_documents?id=#{params[:id]}”, :onclick => “set_as_app()”, :class => “active”

function set_as_app()
  {
      var IDs = [];
      $(“.form_check”).each(function()
      {
        var each_id = ‘#’+this.id;        
        if ($(each_id).attr(‘checked’))
        {            
            IDs.push(this.id);
            $.ajax({
                 url: “/organizations/change_form”,
                 data: { form_id: this.id, org_id: $(‘#org’).val(), season: $(‘#season’).val()},
                 cache: false,                      
            })
        }                  
      });
      
  }
I hope, it will help..!!!

 

 

 

Advertisements

find index of current row


<table>

<tr>
<td class=”bordercolor” >
<a href=”#” class=”up”>Up</a><br>
<a href=”#” class=”down”>Down</a>
</td>

</tr>

</table>

$(document).ready(function(){
$(“.up,.down”).click(function(){
var td= $(this).closest(‘tr’).index();
alert(“Maisa”+td);
});
});