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.

41 lines
1.2KB

  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. // instead be a number based on how many items we have
  18. var newForm = prototype.replace(/__name__/g, index);
  19. // Replace '__name__' in the prototype's HTML to
  20. //$(li).find('div:last-child').remove();
  21. $(li).append(newForm);
  22. $(li).find('#form_entities_' + index + '_id').val($(li).data('id'));
  23. if ($('.lc-sortable').data('parent-position') !=='') val = $('.lc-sortable').data('parent-position') + '_' + index
  24. else val = index;
  25. log($(li).find('#form_entities_' + index + '_position'));
  26. $(li).find('#form_entities_' + index + '_position').val(val);
  27. });
  28. });
  29. }