forms - How to track checkboxes with Django and endless pagination? -
i django noob , have situation goes beyond basic documentation, etc.
i updating ordering webpage has form structured follows:
several text boxes, etc gather general info (name, date, etc)
two separate tables selecting (via checkbox) catalogs generated/managed using endless_pagination. each table can have thousands of records, hence endless_pagination. first column in each table checkbox value = catalog.id.
a textbox user can manually enter catalog ids
a submit button
i not sure how keep track of user has selected in 2 paginated tables since checked boxes lost when choosing different page. also, when user flips , forth between pages, previoulsy checked catalogs need re-checked(since checked state not maintained). not sure tool(s) use deal this.
my thought use javascript (with have minimal experience) update list of catalog ids whenever checkbox checked/unchecked and: - , attach list form or - update variable in form or - send variable separate form, whichever possible/makes more sense.
i'm hoping maintaining list of catalog ids possible because next iteration of form include sort of filtering i'm trying devise solution not have reworked later.
i have reviewed lot of posts believe closest solutions rendered useless because of endless_pagination.
let me know if further clarification required. in advance suggestions.
update
i tried using javascript store catalog ids in array when checkbox checked. not work when user selects page in pagination. array of checked catalog ids lost when page 'reloads'.
i'm running problem right well. i'm handling writing checked items localstorage carry across page 2, 3, etc.. show checked when go page 1. every time page loads, either find , check existing checkbox, or create hidden input appropriate name , value , append main form.
var selected_items = [] function add_item_to_checkbox(item) { localstorage.setitem('selected_items', json.stringify(selected_items)); checkbox.on("click", add_item_to_checkbox);
bahh... @ jsfiddle it's easier read , yeah. don't have type js textarea on stackoverflow.
here javascript minus few things specific code. i'm sure improved upon works application.
Comments
Post a Comment