batchcreate.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. $(function()
  2. {
  3. $(document).on('click', '.addItem', function()
  4. {
  5. var $tr = $(this).parents('tr');
  6. $tr.after(window.itemRow.replace(/KEY/g, window.row));
  7. initSelect($tr.next().find('.picker-select'));
  8. $tr.next().find('.form-date, .form-datetime').datetimepicker(
  9. {
  10. language: config.clientLang,
  11. weekStart: 1,
  12. todayBtn: 1,
  13. autoclose: 1,
  14. todayHighlight: 1,
  15. startView: 2,
  16. minView: 2,
  17. forceParse: 0,
  18. format: 'yyyy-mm-dd'
  19. });
  20. window.row++;
  21. });
  22. $(document).on('click', '.delItem', function()
  23. {
  24. var $tbody = $(this).parents('tbody');
  25. var $tr = $(this).parents('tr');
  26. if($('.delItem').length == 1)
  27. {
  28. $tr.find('input[type=text]:visible,select').val('');
  29. $tr.find('.chosen').trigger('chosen:updated');
  30. $tr.find('.text-error.red').each(function()
  31. {
  32. $(this).prev().css('border-color', '');
  33. $(this).remove();
  34. });
  35. return false;
  36. }
  37. $tr.remove();
  38. $tbody.find('tr:first select').each(function()
  39. {
  40. var picker = $(this).data('zui.picker');
  41. if(picker)
  42. {
  43. picker.removeFromList('ditto');
  44. }
  45. else
  46. {
  47. if($(this).find('option[value=ditto]').length == 1)
  48. {
  49. $(this).find('option[value=ditto]').remove();
  50. var chosen = $(this).data('chosen');
  51. if(chosen) $(this).trigger('chosen:updated');
  52. }
  53. }
  54. });
  55. });
  56. $(document).on('change', 'input,select,textarea,radio,checkbox', function()
  57. {
  58. $(this).css('border-color', '');
  59. $(this).next('.text-error.red').remove();
  60. });
  61. })