Ajax problem


#1

Hi All,

I have an element in a table, and on a callback after an AJAX call I’d
like to change the font-style of the text in the element.

I currently have

Calling view

<%= link_to position.job_title, :action => 'show', :id => position %> <%= position.salary %> <%= position.location %> <%= position.description %> <%= link_to 'Edit', :action => 'edit', :id => position %> <%= link_to 'Destroy', { :action => 'destroy', :id => position }, :confirm => 'Are you sure?' %> <%= link_to_remote('close', :update => "#{position.id}", :url => { :action => :close, :id => position }, :confirm => 'Are you sure you wish to close this position?', :complete => %> <%= link_to 'apply', { :action => 'apply', :id => position }, :confirm => 'Are you sure you wish to apply for this position?' %>
Controller

def close
position = Position.find(params[:id])
position.close
if position.save
render(:layout => false)
end
end

returned view

<%= update_element_function(
‘1’, :action => :update, <something?>
) %>

I’ve been trying to track this down for a while now and I can’t find an
example of anything similar. Does anyone have an example of something
that manipulates the original text of the div? Most examples of
link_to_remote seem to add text, I haven’t seen anything that alters the
text style

Kev


#2

You don’t want the :update => ‘element_id’ parameter in that case (as
you’re not going to update the contents of the element).

You want

:complete => "$('#{position.id}").style.textDecoration = 'line-

through’"

without the :update stuff. (note this is from memory, untested!).

Cheers,
Thomas

Am 09.11.2005 um 11:22 schrieb Kev J.: