0
3应用程序,还有一个select_tag与平变化事件,该事件发送AJAX请求:其中,goAjax是js.erb被称为仅在第一次在我导轨
f.select 'forma_id', @collection, {:include_blank => true}, {:onchange => "goAjax('/lancamentos/receber_forma', this.value)", :class => 'btn'}
:
function goAjax(_url, _value) {
$.ajax({url: _url, data: 'value=' + _value, dataType: 'script'})
}
lancamentos_controller#receber_forma是(简化版本):
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
和receber_forma.js.erb:
$('div#cartoes').replaceWith("<%= escape_javascript(label_tag(@lancamento.forma_id)) %>");
正在发生的事情是,当我选择上选择一个值,呈现在标签上的值总是在价值上发送第一次通话。以下值更改根本不会更改标签文本。方法receber_forma中的记录器显示总是发送新的选定值。
有人知道我在做什么错在这里?
p.s.:sorry英语
感谢迪伦......解决了这个问题! – thaleshcv 2012-04-09 18:43:48