nathanvda/on_the_spot — Issue #38: Doesn't work in partial rendered via JQuery without a page refresh
Author: betjamin
Created: 2012-01-26 23:39:13+00:00
State: open

(Nathan, I feel like I'm peppering you with these. I'm sorry!)

So this is weird one.

I have a list of objects that gets rendered via a partial for each object. When a new object is created it fires off some javascript and prepends the new object to the list without refreshing the page (via JQuery).

The title of each object is editable via on_the_spot, and I can click on any title in the list and it is editable.

However, when a new object is inserted into the list and I click on the title nothing happens. Yet, if I click any other title of an object in the list the on_the_spot function works. If I then refresh my page and click on the title of the new object it works.

When I investigate the outputted HTML code it seems to be identical:

Code for the new object that is inserted into the list - **Doesn't work:**

```HTML

The description

```

Code for an existing object in the list - **Works:**

```HTML

The description

```

The only discernable difference I can spot is the inclusion of a "title=" param in the code that works.

The partial also includes some other javascript to expand and collapse the object in the list. This works fine which would seem to rule out any javascript issues in the actual partial or the way it is rendered.

Any insight would be greatly appreciated.