Forum: Ruby on Rails ajax problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2a0f7bd2c54fbc44329d69555b96f1c5?d=identicon&s=25 kevin.jackson (Guest)
on 2005-11-12 12:49
(Received via mailing list)
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
 <div id='<%= position.id %>'>
  <tr>
    <td align="left" valign="top"><%= link_to position.job_title,
:action => 'show', :id => position %></td>
    <td align="left" valign="top"><%= position.salary %></td>
    <td align="left" valign="top"><%= position.location %></td>
    <td align="left">
    </td>
  </tr>
  <tr>
    <td align="left" rowspan="5" colspan="3"><%= position.description
%></td>
    <tr><td><%= link_to 'Edit', :action => 'edit', :id => position
%></td></tr>
    <tr><td><%= link_to 'Destroy', { :action => 'destroy', :id =>
position }, :confirm => 'Are you sure?' %></td></tr>
    <tr><td><%= link_to_remote('close',
                :update => "#{position.id}",
                 :url => { :action => :close, :id => position },
                :confirm => 'Are you sure you wish to close this
position?',
                :complete => <do something?> %></td></tr>
    <tr><td><%= link_to 'apply', { :action => 'apply', :id => position
}, :confirm => 'Are you sure you wish to apply for this position?'
%></td></tr>
  </tr>
 </div>
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
E813e9cc70159e103a64a5237c0d3ee2?d=identicon&s=25 t.fuchs (Guest)
on 2005-11-12 12:49
(Received via mailing list)
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 Jackson:
This topic is locked and can not be replied to.