Support

Account

Home Forums Add-ons Repeater Field programmatically reorder repeater row

Solving

programmatically reorder repeater row

  • I have a checkbox that reveals a WYSIWYG associated with a text field in a row. What I would like to do is when the checkbox is checked the row slides up to the top or below the latest row that has a checked checkbox ( and to the bottom if unchecked). In effect creating two groups: rows with description and rows that are just list items. I have the sorting all done on the page output, this is just for the benefit of the editor. I don’t need a solution just some pointers on the php/js files to look at and whether it’s in the core, acf or repeater plugin.

    A similar example is the way google keep does it with checkbox list – if item is checked it moves down into “crossed-out” section if unchecked moves to the bottom of the “active” task list.

  • this was helpful for getting the row positioned to the right place without dragging:
    http://stackoverflow.com/questions/4928002/jquery-sortable-set-item-to-an-index-programmatically
    Still looking if it’s possible to have acf update row numbers and the db.
    I can’t find where these type of function are located:
    in repeater input.js – ‘acf/sortable_stop_repeater’ and in repeater.php ‘acf/update_field/type=’

  • so calling acf.fields.repeater.set({$el: acf.fields.repeater.$el}).render();
    after the insert allows for the new row locations to get saved on post update, but the row numbers are not correct until after the page is reloaded. I also suspect that the two functions that move into accordion and list can be added to the repeater object, but not really clear on how this works in js.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘programmatically reorder repeater row’ is closed to new replies.