Skip to content

Instantly share code, notes, and snippets.

@devoutdesign
devoutdesign / valums-file-uploader-example.js
Created September 15, 2010 17:19
An example of using valums file uploader and how to modify the list item onComplete
var uploader = new qq.FileUploader({
onComplete: function(id, filename, responseJSON) {
if (responseJSON.success) {
var item = uploader._getItemByFileId(id);
var myElement = uploader._getElement(item, 'myCustomClass');
myElement.style.display = 'inline-block';
}
},
fileTemplate:
'<li>' +
<%= form_for(@chapter) do |f| %>
<% if @chapter.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@chapter.errors.count, "error") %> prohibited this chapter from being saved:</h2>
<ul>
<% @chapter.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
class ChaptersController < ApplicationController
respond_to :html, :xml, :json
# GET /books/1/chapters/new
def new
@book = Book.find(params[:book_id])
@chapter = @book.chapters.new
respond_with(@chapter)
end