· 1 min read

Screencast: Im Browser "In-Place" Editieren

Downloads in verschiedenen Formaten:

mp4 m4v webm ogg

Resourcen:

Gemfile

[ruby] gem ‘best_in_place’ [/ruby]

app/assets/javascripts/application.js

[javascript] //= require jquery.purr //= require best_in_place [/javascript]

app/assets/javascripts/users.js.coffee

[javascript] jQuery -> $(‘.best_in_place’).best_in_place() [/javascript]

users/show.html.erb

[html]

Name: <%= best_in_place @user, :name %>

Email: <%= best_in_place @user, :email %>

Gender: <%= best_in_place @user, :gender, type: :select, collection: [[“Male”, “Male”], [“Female”, “Female”], ["", “Unspecified”]] %>

Public profile: <%= best_in_place @user, :public_profile, type: :checkbox, collection: %w[No Yes] %>

<%= best_in_place @user, :bio, type: :textarea %>

[/html]

users_controller.rb

[ruby] respond_to :html, :json def update @user = User.find(params[:id]) @user.update_attributes(params[:user]) respond_with @user end [/ruby]

app/assets/stylesheets/users.css.scss

[css] .purr { position: fixed; top: 30px; right: 100px; width: 250px; padding: 20px; background-color: #FCC; border: solid 2px #C66; &:first-letter { text-transform: uppercase; } } [/css]

Back to Blog