Advertisement
Guest User

Untitled

a guest
Apr 21st, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. $("#AddLinkDiv a").on("click", function () {
  2. $.ajax({
  3. url: "../../DrugArticles/EditHandledPropertiesRow/" + $("#NplPackId").val(),
  4. cache: false,
  5. success: function (data) {
  6. $("#EditDrugArticleTable tr").last().after(data);
  7. $("#EditDrugArticleTable tr").last().addClass("ToBeAdded");
  8. window.onbeforeunload = function() {
  9. return 'Are you sure you want to leave?';
  10. };
  11. addDatePicker();
  12. },
  13. dataType: "html"
  14. });
  15. return false;
  16. });
  17.  
  18. if ($("#EditDrugArticleTable .State[Value='New']").find("tr").length == 0) {
  19. window.onbeforeunload = null;
  20. }
  21.  
  22. $("#EditDrugArticleTable").on("click", "td.Delete a", deleteRow);
  23.  
  24. function deleteRow() {
  25. var parentRow = $(this).parent().parent();
  26. var state = parentRow.find("input.State").val();
  27. if (state == "Existing") {
  28.  
  29. parentRow.addClass("ToBeDeleted");
  30. parentRow.find("input").not("[type='hidden']").prop("disabled", true);
  31. parentRow.find("input.State").val("Deleted");
  32.  
  33. $(this).toggleClass("backStage");
  34. $(this).attr("title", "Ångra");
  35. window.onbeforeunload = function() {
  36. return 'Are you sure you want to leave?';
  37. };
  38. }
  39. else if (state == "Deleted") {
  40.  
  41. parentRow.removeClass("ToBeDeleted");
  42. parentRow.find("input").prop("disabled", false);
  43. if (!parentRow.find("input.Procured").is(":checked")) {
  44. parentRow.find("input.Price").prop("disabled", true);
  45. }
  46. parentRow.find("input.State").val("Existing");
  47.  
  48. $(this).toggleClass("backStage");
  49. $(this).attr("title", "Ta bort");
  50. if ($("#EditDrugArticleTable").prop(".State[Value='New']")) {
  51. window.onbeforeunload = null;
  52. }
  53. }
  54. else if (state == "New") {
  55. parentRow.remove();
  56. if ($("#EditDrugArticleTable").prop(".State[Value='New']")) {
  57. window.onbeforeunload = null;
  58. }
  59. }
  60. return false;
  61. }
  62.  
  63. var parentRow = $(this).parent().parent();
  64. var state = parentRow.find("input.State").val();
  65.  
  66. if (state == "Existing") {
  67. ...
  68. }
  69. else if (state == "Deleted") {
  70. ...
  71. }
  72. else if (state == "New") {
  73. ...
  74. }
  75.  
  76. ckeckUnloadEvent();
  77.  
  78. return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement