Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7764243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:51:40+00:00 2026-06-01T14:51:40+00:00

in my rails 3 application, there is a select_tag with an onchange event, which

  • 0

in my rails 3 application, there is a select_tag with an onchange event, which sends an ajax request:

f.select 'forma_id', @collection, {:include_blank => true}, {:onchange => "goAjax('/lancamentos/receber_forma', this.value)", :class => 'btn'}

where, goAjax is:

function goAjax(_url, _value) {
  $.ajax({url: _url, data: 'value=' + _value, dataType: 'script'})
}

lancamentos_controller#receber_forma is (simplified version):

def receber_forma
  @lancamento = Lancamento.new(:forma_id => params[:value])
  logger.info 'forma_id = ' + @lancamento.forma_id
  respond_to do |format|
    format.html { render :new }
    format.js
  end
end

and receber_forma.js.erb:

$('div#cartoes').replaceWith("<%= escape_javascript(label_tag(@lancamento.forma_id)) %>");

what is happening, is that when I choose a value on that select, the value rendered on the label is always the value sent on first call. The following value changes simply don’t change the label text. The logger in the method receber_forma shows that the new selected value is always sent.

Someone knows what I’m doing wrong here??

p.s.:sorry any errors of English

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T14:51:42+00:00Added an answer on June 1, 2026 at 2:51 pm

    You’re completely replacing your div#cartoes with a label, so the second time the code runs, it can’t find a div with the cartoes id. You probably want to use .html instead of .replaceWith, so that the label becomes the content of the div rather than replacing it altogether:

    $('div#cartoes').html("<%= escape_javascript(label_tag(@lancamento.forma_id)) %>");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an rails 3 application where there are multiple registrations (diagnosis, patient, laboratory
If there's an exception in a Rails application, one gets an error page with
Is there an equivalent of htmlspecialchars_decode (PHP) in Ruby (for a Ruby-on-Rails application) Or
My Rails application has a number of tasks which are offloaded into background processes,
In my rails application ,iam using jqgrid to enter data in rows.there is a
I have the following code in my Rails 3 application. @clinical_healthplan_spend = Clinical.select(ClientKey as
I'm trying to implement switch_user gem in my existing rails 3.0.9 application. There are
Is there a quick way to pack a jruby on rails application into a
I have a rails application which acts differently depending on what domain it's accessed
I have a rails application that has three different types of users and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.