简体   繁体   中英

how to customize jquery.formset.js django

i have created a form with inlineformset_factory with jquery.formset.js library for increasing rows , but i cant change default position of add and delete buttons , this is the library i have used [https://cdnjs.cloudflare.com/ajax/libs/jquery.formset/1.2.2/jquery.formset.js 1

and this is the template's view在此处输入图片说明

and this is the script

 <script> $(function(){ $('.tb1 tr:last').formset({ prefix:'{{items.prefix}}', addText:'add', addCssClass:'add-row btn btn-info', deleteText:'delete', deleteCssClass:' delete-row btn btn-danger', added:function($row){ $('.item').select2(); } }) $(".item").select2(); }) </script>

i want to push delete and add buttons both in one row

 <tr style="background-color: #5dbcd3;color: #ffffff;"> <th> <div> <button type="button" class="btn btn-success" id="add">+</button> </div> </th> <th class="btn btn-danger" id="del"> <button type="button" class="btn btn-danger" id="delete">-</button> </th> </tr>

is there a way to customize it ? i know i have to change some codes in the jquery.formset.js library , i dont know how to do it ! i tried alot ..

thanks for answering ..

Use the default button that comes with the library.

And locate them in an extra field at the bottom of the table, since if you're using Django Admin when you send a POST request you are resending all the document and extracting what matches your needs.

Hope this comment helps even when there's no snippet, if not, write me back, I wanted to answer you ASAP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM