ruby on rails - Return js code from an action without using js.erb -
instead of doing:
def edit @user = user.find params[:id] respond_to { |format| format.js } end #edit.js.erb // js code
is there way same thing in controller's action this:
def edit @user = user.find params[:id] respond_to { |format| format.js /* js code*/ } end
you can write codes this
format.js { render :js => "alert('hello rails');" }
also
format.js { render :js => "window.location.replace('#{your_url(@object)}');" }
Comments
Post a Comment