Women in Technology

Hear us Roar



Article:
  Ajax on Rails
Subject:   can ajax be used for updating two or more div's simultaniously
Date:   2006-09-14 09:22:52
From:   EpsilonsDad
Response to: can ajax be used for updating two or more div's simultaniously

After playing with this I have found that you can take advantage of the fact that the rails ajax framework evaluates javascript within the response. So the response hander to fill two divs could be something like this.


def response_handler
#content for div1
@text = "New text in div1"
#content for div2
@text += "<script language=\"javascript\" >document.all.div2.innerHTML='New text in div2';</script>"
render :text => @text
end


Which should update mutilple blocks