0
votes

I'm having an issue with UJS, jQuery and partials. I have a table with a bunch of rows. When I click edit on one of the rows, the row transforms into text fields where I can edit the row. Then I have a submit; however, clicking it does nothing. It just doesn't look like its triggering. Clicking edit sends a call to the controller, which responds with edit.js.erb which has jQuery replace the contents of the row with the edit partial.

Is there anything obvious I'm overlooking? I'd post code, but am on my phone and can't get online on the computer. I'll edit later if I can't figure it out. I was hoping for some feedback in the meantime.

Thanks

Ok, here's some code:

Item controller:

    def edit
        respond_to do |format|  
            format.html { respond_with @item }
            format.js { } 
        end
    end
    def update
        @item.update_attributes(params[:item])
        respond_to do |format|  
            format.html { respond_with @item, :location => items_path }
            format.js { } 
        end     
    end  

edit.html.erb: <%= form_for(@item, item_path) do |form| %> <%= render form %> <% end %>

edit.js.erb:

$(' .item ').html(" 'item/edit', :locals => {:item => @item})) %>");

update.js.erb:

$(' .item ').html(" 'item/item', :item => @item) %>");
1

1 Answers

0
votes

It actually ended up being an issue with html closing my form tag prematurely. I didn't know you couldn't put a form in a table cell. I had stared at the source for so long and couldn't see what was wrong.

If this is happening to you, make sure you check where your closing form tag is.