Created
February 7, 2013 15:46
-
-
Save batdevis/4731761 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_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