Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $("#AddLinkDiv a").on("click", function () {
- $.ajax({
- url: "../../DrugArticles/EditHandledPropertiesRow/" + $("#NplPackId").val(),
- cache: false,
- success: function (data) {
- $("#EditDrugArticleTable tr").last().after(data);
- $("#EditDrugArticleTable tr").last().addClass("ToBeAdded");
- window.onbeforeunload = function() {
- return 'Are you sure you want to leave?';
- };
- addDatePicker();
- },
- dataType: "html"
- });
- return false;
- });
- if ($("#EditDrugArticleTable .State[Value='New']").find("tr").length == 0) {
- window.onbeforeunload = null;
- }
- $("#EditDrugArticleTable").on("click", "td.Delete a", deleteRow);
- function deleteRow() {
- var parentRow = $(this).parent().parent();
- var state = parentRow.find("input.State").val();
- if (state == "Existing") {
- parentRow.addClass("ToBeDeleted");
- parentRow.find("input").not("[type='hidden']").prop("disabled", true);
- parentRow.find("input.State").val("Deleted");
- $(this).toggleClass("backStage");
- $(this).attr("title", "Ångra");
- window.onbeforeunload = function() {
- return 'Are you sure you want to leave?';
- };
- }
- else if (state == "Deleted") {
- parentRow.removeClass("ToBeDeleted");
- parentRow.find("input").prop("disabled", false);
- if (!parentRow.find("input.Procured").is(":checked")) {
- parentRow.find("input.Price").prop("disabled", true);
- }
- parentRow.find("input.State").val("Existing");
- $(this).toggleClass("backStage");
- $(this).attr("title", "Ta bort");
- if ($("#EditDrugArticleTable").prop(".State[Value='New']")) {
- window.onbeforeunload = null;
- }
- }
- else if (state == "New") {
- parentRow.remove();
- if ($("#EditDrugArticleTable").prop(".State[Value='New']")) {
- window.onbeforeunload = null;
- }
- }
- return false;
- }
- var parentRow = $(this).parent().parent();
- var state = parentRow.find("input.State").val();
- if (state == "Existing") {
- ...
- }
- else if (state == "Deleted") {
- ...
- }
- else if (state == "New") {
- ...
- }
- ckeckUnloadEvent();
- return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement