Skip to content

Instantly share code, notes, and snippets.

@batdevis
Created February 7, 2013 15:46
Show Gist options
  • Save batdevis/4731761 to your computer and use it in GitHub Desktop.
Save batdevis/4731761 to your computer and use it in GitHub Desktop.
_properties.html.erb:
<dd class="edit_bpm editable"><%= song.try(:bpm) || '---' %></dd>
songs_controller.rb:
def pupdate
#update only one attribute
#used for inplace edit
a = params[:song].first
@song.update_attribute a[0], a[1]
respond_with @song, location: band_song_url(@band, @song) do |format|
format.js { render text: @song.send(a[0]) }
end
end
songs.js:
$(function() {
var set_editables = function() {
//http://www.appelsiini.net/projects/jeditable
/*** song bpm ***/
var song_url = "/bands/" + gon.band_id + "/songs/" + gon.song_id + "/pupdate.js";
$('.edit_bpm').editable(song_url, {
tooltip : 'click to edit...',
cancel : 'cancel',
submit : 'save',
select : false,
method : 'PUT',
name : 'song[bpm]',
placeholder: '---'
});
};
set_editables();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment