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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -