You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.1KB

  1. jQuery(document).ready(function() {
  2. custom_switch_merchants() ;
  3. setSortableList();
  4. }) ;
  5. function custom_switch_merchants() {
  6. $('#switch-merchant select').change(function() {
  7. $('#switch-merchant form').submit() ;
  8. }) ;
  9. }
  10. function setSortableList() {
  11. $('.lc-sortable tbody').sortable({
  12. placeholder: "ui-state-highlight"
  13. });
  14. $('.lc-sortable tbody').on("sortupdate", function (event, ui) {
  15. prototype = $('#form_entities').data('prototype');
  16. $('.lc-sortable tr.lc-draggable').each(function (index, li) {
  17. // Replace '__name__' in the prototype's HTML to
  18. // instead be a number based on how many items we have
  19. var newForm = prototype.replace(/__name__/g, index);
  20. $(li).append(newForm);
  21. $(li).find('div:last-child').remove();
  22. $(li).find('#form_entities_' + index + '_id').val($(li).data('id'));
  23. log($('.lc-sortable').data('parent-position')+'_'+index);
  24. $(li).find('#form_entities_' + index + '_position').val($('.lc-sortable').data('parent-position')+'_'+index);
  25. });
  26. });
  27. }