Jamgreen
Jamgreen

Reputation: 11039

Add and delete buttons in django jquery dynamic formset

I use https://github.com/elo80ka/django-dynamic-formset to add and delete rows from a formset.

The problem is that the add row and delete row buttons are automatically inserted weird places.

Can I place these buttons manually?

Or are there any other jquery libraries to add and delete rows in a formset dynamically?

Upvotes: 0

Views: 2269

Answers (1)

I don't think you can place these buttons manually, maybe if you check the rules followed by the plugin to place the buttons: https://github.com/elo80ka/django-dynamic-formset/blob/master/src/jquery.formset.js#L49

As you can see:

//If the forms are laid out in table rows, insert // the remove button into the last table cell

// If they're laid out as an ordered/unordered list, // insert an < li > after the last list item

// Otherwise, just insert the remove button as the // last child element of the form's container

You can specify addCssClass (which is by default 'add-row'), maybe that can help you.

Upvotes: 2

Related Questions