Sortable_element - Altering defaults set by rails

Hi there, I’ve got the following code to generate two sortable elements
but whenever someone drags and drops an item, i only want it to return a
serialised list of the items in categoryartworks, the unlinkedartworks
can be in any order and I don’t care. I can then delete those artworks
that were in category artworks but aren’t in the serialised list, plus
reorder the category artworks. Here’s the code:

<%= sortable_element ‘categoryartworks’,
:dropOnEmpty => true,
:containment => [“categoryartworks”,“unlinkedartworks”],
:constraint => false,
:parameters => “Sortable.serialize(“categoryartworks”)”,
:url => { :action => “order”,
:category => @category.id,
}

  %>

<%= sortable_element ‘unlinkedartworks’,
:dropOnEmpty => true,
:containment => [“categoryartworks”,“unlinkedartworks”],
:constraint => false,
:parameters => “Sortable.serialize(“categoryartworks”)”,
:url => { :action => “order”,
:category => @category.id,
}

  %>

The trouble is that rails generates this (repeats the parameters):


I want to override the default rails entry there and replace it with my
call to Sortable.serialise, right now It’s displaying both of them which
breaks the app.

I know this is probably just a basic syntax issue but how do I get it
done?

Cheers,

Brendon M.

To answer my own question (After much searching through poor
documentation, use this:

:with => “Sortable.serialize(“categoryartworks”)”

as in:

<%= sortable_element ‘unlinkedartworks’,
:dropOnEmpty => true,
:containment => [“categoryartworks”,“unlinkedartworks”],
:constraint => false,
:url => { :action => “order”,
:category => @category.id
},
:with => “Sortable.serialize(“categoryartworks”)”
%>

Cher!

Brendon

Brendon M. wrote:

Hi there, I’ve got the following code to generate two sortable elements
but whenever someone drags and drops an item, i only want it to return a
serialised list of the items in categoryartworks, the unlinkedartworks
can be in any order and I don’t care. I can then delete those artworks
that were in category artworks but aren’t in the serialised list, plus
reorder the category artworks. Here’s the code:

<%= sortable_element ‘categoryartworks’,
:dropOnEmpty => true,
:containment => [“categoryartworks”,“unlinkedartworks”],
:constraint => false,
:parameters => “Sortable.serialize(“categoryartworks”)”,
:url => { :action => “order”,
:category => @category.id,
}

  %>

<%= sortable_element ‘unlinkedartworks’,
:dropOnEmpty => true,
:containment => [“categoryartworks”,“unlinkedartworks”],
:constraint => false,
:parameters => “Sortable.serialize(“categoryartworks”)”,
:url => { :action => “order”,
:category => @category.id,
}

  %>

The trouble is that rails generates this (repeats the parameters):


I want to override the default rails entry there and replace it with my
call to Sortable.serialise, right now It’s displaying both of them which
breaks the app.

I know this is probably just a basic syntax issue but how do I get it
done?

Cheers,

Brendon M.