Calling another rjs file in an if condition

Hi
I have a controller action like below.This def is called by a
submit_to_remote
def edit_service_desk_status_after_transfer
if params[:transfer_reason].empty?
#This is used in the :failure of submit_to_remote
else
@sd_ticket = ServiceDeskTicket.find(params[:sd_id])
ActiveRecord::Base.transaction do
@sd_status_history = ServiceDeskStatusHistory.new
@sd_status_history.service_desk_ticket_id = @sd_ticket.id
@sd_status_history.service_desk_status_id =
@sd_ticket.service_desk_status_id
@sd_status_history.save
@sd_ticket.update_attribute(“service_desk_status_id”,params[:status_id])
end #end of transaction
if params[:page]==‘search_sd_ticket’
render :update do |page|
#page[:flow_item_find_search_sd].replace_html
“service_desk_part/service_desk_flow_item_find_search_sd”,
:locals=>{:sd_ticket=>@sd_ticket}
end
end
#The below portion i dont want to execute if the above condition
satisfied
@[email protected]_ticket.service_desk_status_histories
-------code
end

In the above what i am trying to do is if the if condition
if params[:page]==‘search_sd_ticket’ is satisfied call another rjs
instead of the default rjs file
edit_service_desk_status_after_transfer.rjs .The above is not working
.How can I do that…And I need not execute code after the if , if the
condition is ok…Just load another rjs which has the code to replace
some other divs rather than the default rjs does

Sijo

On Tue, May 13, 2008 at 12:21 AM, Sijo Kg
[email protected] wrote:

In the above what i am trying to do is if the if condition
if params[:page]==‘search_sd_ticket’ is satisfied call another rjs
instead of the default rjs file

You can render an alternate RJS file with render.

render :controller => :foo, :action => :alternate_bar

You can also just use an if/else in the RJS file.


Greg D.
http://destiney.com/

Hi
Thanks for your reply.It worked
Sijo

Hi
The above problem solved .But this too related to that problem .So I
am posting in the same place.I have One more question related to this…I
am calling the above function from different views but with differnt
params…For example from one view page when i call this through
submit_to_remote a particular param params[:page] is not passing .But
from one other place I have to pass this param.Will this create any
problem.Or this anything related to route.rb?Why i am asking this I had
already this working…But as I said earlier last day i called this same
function using submit_to_remote from another view with a param
params[:page]=“search_sd_ticket” and checked it in an if else …So that
is working…But the alredy working code now shows a failure from the
other view?What might be the reason?Can’t i pass or not pass differnet
params to the same function?

Thanks in advance
Sijo

It will be easier to help if you let us know what the failure is.

To answer your base question, the controller does not know or care
where the request comes from. It will inspect the query string (via
params), find the appropriate data to satisfy the request, and
generate the response regardless of who asked for it or how (data
problems excepted obviously).

One possibility would be that the rjs you generate may be trying to
update a specific element on the page that only exists in one of the
places that you call the action. You can code around that by using
the page.select(…).any or by simply rendering the results and
using :update on the ajax call. The choice lies in how many updates
you make in your ajax response.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs