简体   繁体   中英

respond_to does not redirect to new url

In all other methods it works fine with format.html, but in this one with format.js it updates the view but the visible url remains the same

 respond_to do |format|
 format.html { redirect_to some_path }
 format.js { redirect_to(:action => :index, :format => :js, :date => day}
 end

if I change the date the view won't refresh either:

 format.js { redirect_to(:action => :index, :format => :js, :date => params[:date])}

If i comment out format.html everything works the same way.

Do I need to update_attributes or somehow refresh the hidden_value? Or add another redirect? What could I be doing wrong?

format.js应该返回js代码,因此在这种情况下,您必须更改为

format.js { "window.location = 'your url';" }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM