form_field_labels.html 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. <div id="__id__wrapper">
  2. <div id="__id__" class="bx-form-input-autotoken bx-form-input-autotoken-labels bx-def-font-inputs bx-form-input-text">
  3. __value__
  4. </div>
  5. <div class="bx-form-input-autotoken bx-form-input-autotoken-labels bx-form-input-autotoken-labels-sel">
  6. __values__
  7. </div>
  8. </div>
  9. <script>
  10. var fCallack = function () {
  11. // adding label
  12. if ($(this).parents('.bx-form-input-autotoken-labels-sel').length) {
  13. var e = $(this).remove().on('click', fCallack);
  14. e.append('<input type="hidden" name="__name__[]" value="' + e.text() + '">');
  15. $("#__id__").append(e);
  16. }
  17. // removing label
  18. else if ($(this).parent('#__id__').length) {
  19. var e = $(this).remove().on('click', fCallack);
  20. e.find('input').remove();
  21. $("#__id__wrapper .bx-form-input-autotoken-labels-sel").prepend(e);
  22. }
  23. };
  24. $("#__id__wrapper b").on('click', fCallack);
  25. // show more
  26. $("#__id__wrapper .bx-form-input-autotoken-labels-show-more").on('click', function () {
  27. $(this).hide();
  28. $("#__id__wrapper .bx-form-input-autotoken-labels-more").show();
  29. return false;
  30. });
  31. </script>