Generated html not sortable?

Hi,

I'm using the rails sortable_element helper on a list and after it has
been sorted I have used this code:
  page['page_' + p.id.to_s].replace :partial => 'page', :locals =>
{ :page => p }

to replace the list items that changed order as the html has to
change.

The problem is that any of the list items that are 'replaced' are now
not sortable. Is this expected behavior and is there a fix or a
workaround?

thanks,

DAZ

I've found a bit of a hack solution.

If I change replace to replace_html, it works. I guess that this is
because the id is in the <li> and if I use replace_html, the original
<li> stays there. The problem with this approach is that the generated
html is a bit rubbish - there will be a nested <li> inside the
original <li> and they will both have the same id.

Is this acceptable or is there a better/correct way of doing this?

cheers,

DAZ

my 'hack' doesn't work too well, as it introduces loads of problems if
you then try to sort again as the array that is sent to the sort
action gets messed up.....oh well, it seems that you can't seem to do
any JS tricks with generated content.

DAZ

Hi DAZ,

DAZ wrote:

my 'hack' doesn't work too well, as it introduces loads
of problems if you then try to sort again as the array that
is sent to the sort action gets messed up.....oh well, it
seems that you can't seem to do any JS tricks with
generated content.

Have you tried just doing a replace_html on the <ol> or <ul> surrounding
your <li>s? I've just been fighting with something that may be related.
Haven had enough time to isolate the problem further, but when I render a
partial with an observe_field in it 'normally, the <script> shows up in
FireBug. When I render the same partial via RJS, it disappears. The
actions still fire, but I lose the debug ability I so_much rely on with
FireBug.

HTH,
Bill